私の一般的なページ設定では、テンプレートを次のように定義します。page.10.template.file = fileadmin/template.html
このテンプレートで MVC ViewHelper を呼び出す方法はありますか? スニペット
{namespace xyz=PATH\TO\MY\ViewHelpers}
<xyz:myhelper argument="abc" />
上記のテンプレートでは機能せず、そのまま表示されます。
私の一般的なページ設定では、テンプレートを次のように定義します。page.10.template.file = fileadmin/template.html
このテンプレートで MVC ViewHelper を呼び出す方法はありますか? スニペット
{namespace xyz=PATH\TO\MY\ViewHelpers}
<xyz:myhelper argument="abc" />
上記のテンプレートでは機能せず、そのまま表示されます。
ページ テンプレートにどの cObject を使用しているかは、私には 100% 明確ではありません。ページ テンプレートで Fluid ViewHelpers を使用する場合は、ページ テンプレートに FLUIDTEMPLATE を使用することをお勧めします。
1.流体テンプレート
ページ テンプレートにFLUIDTEMPLATEを使用する場合、使用可能な ViewHelper (FLUID またはその他の ExtBase/Fluid 拡張機能から) をテンプレートで直接使用できます (以下の例を参照)。
タイポスクリプト
page = PAGE
page.10 = FLUIDTEMPLATE
page.10 {
template = FILE
template.file = fileadmin/templates/template.html
partialRootPath = fileadmin/templates/Partials/
layoutRootPath = fileadmin/templates/Layouts/
variables {
content < styles.content.get
content.select.where = colPos=1
}
}
ファイルの内容: fileadmin/templates/template.html
{namespace xyz=NAMESPACE\EXTENSION\ViewHelpers}
<f:layout name="Main" />
<f:section name="Content">
<xyz:myhelper argument="abc" />
<f:format.html parseFuncTSPath="">{content}</f:format.html>
</f:section>
ファイルの内容: fileadmin/templates/Layouts/Main.html
<f:render section="Content" />
2. テンプレート
TEMPLATEを (マーカーとサブパーツと共に) 使用する場合、そのテンプレートで Fluid ViewHelpers を直接使用することはできません。ただし、以下に示すように、FLUID ViewHelper をレンダリングするマーカーを定義できます。
タイポスクリプト
page = PAGE
page.10 = TEMPLATE
page.10 {
template = FILE
template.file = fileadmin/templates/template.html
marks {
CONTENT < styles.content.get
VIEWHELPER = FLUIDTEMPLATE
VIEWHELPER {
template = FILE
template.file = fileadmin/templates/viewhelper.html
partialRootPath = fileadmin/templates/Partials/
layoutRootPath = fileadmin/templates/Layouts/
}
}
workOnSubpart = DOCUMENT
}
ファイルの内容: fileadmin/templates/template.html
<!--###DOCUMENT### Start-->
###VIEWHELPER###
###CONTENT###
<!--###DOCUMENT### end-->
ファイルの内容: fileadmin/templates/viewhelper.html
{namespace xyz=NAMESPACE\EXTENSION\ViewHelpers}
<f:layout name="Main" />
<f:section name="Content">
<xyz:myhelper argument="abc" />
</f:section>
ファイルの内容: fileadmin/templates/Layouts/Main.html
<f:render section="Content" />