[英]Twig template not receiving variables
我有一個CMS頁面,其中包含一個名為pageTitle
的組件,該組件將顯示格式化的頁面標題。 我正在嘗試將變量傳遞給該組件,但似乎沒有收到它。 我的頁面中有以下內容:
title = "Test"
[pageTitle]
title="Test"
==
{% component 'pageTitle' title="Test" %}
(我認為)應該使用3種不同的方式將變量傳遞給該組件,並且在我擁有的components/pagetitle/default.htm
中(以及其他HTML):
{{ title }}
HTML可以很好地呈現,但是不輸出變量。
我還嘗試將以下內容放入我的components/pagetitle/PageTitle.php
主類文件中:
public function defineProperties()
{
return [
'title' => [
'title' => 'Title',
'description' => 'The page title',
'type' => 'string',
],
];
}
但是,這也沒有效果。
如果我添加標頭部分,可能還需要注意在我的components/pagetitle/default.htm
,例如:
title = "Test"
==
HTML content here
整個內容顯示在輸出HTML中,包括標題。 所以我想知道它是否被Twig解釋器以外的其他東西解釋。
嗯,我很確定沒有什么可攔截的。
你能嘗試這個嗎,因為它在我本地工作
<div id="tile-area">
<h1>default one {{ __SELF__.property('title') }}</h1>
</div>
它應該工作。
您還可以從這里獲取更多參考: https : //octobercms.com/docs/plugin/components#component-properties
如有疑問請發表評論
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.