在普通页面设置中,我将模板定义为:page.10.template.file = fileadmin/template.html
有没有方法在这个模板中调用MVC ViewHelper?小片段
{namespace xyz=PATH\TO\MY\ViewHelpers}
<xyz:myhelper argument="abc" />不工作在上述模板,它是表面的原样。
发布于 2015-01-04 12:35:34
这不是100%清楚,您使用的页面模板的cObject。如果您想在页面模板中使用Fluid ViewHelpers,那么我建议您的页面模板使用FLUIDTEMPLATE。
1. FLUIDTEMPLATE
如果您使用流线型作为页面模板,那么您可以在模板中直接使用任何可用的ViewHelper (来自流体或任何其他ExtBase/Fluid扩展)(参见下面的示例)。
TypoScript
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/模板/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/模板/Layouts/main.html
<f:render section="Content" />2.模板
如果您使用模板 (带有标记和子部件),那么您就不能在模板中直接使用流体ViewHelpers。但是您可以定义一个标记,它呈现流体ViewHelper,如下所示。
TypoScript
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/模板/template.html
<!--###DOCUMENT### Start-->
###VIEWHELPER###
###CONTENT###
<!--###DOCUMENT### end-->文件内容:fileadmin/templates/viepuper.html
{namespace xyz=NAMESPACE\EXTENSION\ViewHelpers}
<f:layout name="Main" />
<f:section name="Content">
<xyz:myhelper argument="abc" />
</f:section>文件内容:fileadmin/模板/Layouts/main.html
<f:render section="Content" />https://stackoverflow.com/questions/27764363
复制相似问题