简体   繁体   English

如何在TYPO3流体模板中调用实体方法?

[英]How do I call an entity method in a TYPO3 fluid template?

I have a template with a line like this: 我有一个带有这样一行的模板:

<f:format.htmlentitiesDecode>
    {product.features}
</f:format.htmlentitiesDecode>

where "features" is an attribute of the "product" data model. 其中“功能”是“产品”数据模型的属性。

I would like to print the result if a method call on product instead. 如果要在product上调用方法,我想打印结果。 Something like: 就像是:

<f:format.htmlentitiesDecode>
    {product.getStrippedFeatures}
</f:format.htmlentitiesDecode>

but that gives me empty content. 但这给了我空洞的内容。

How can I call a method in the product model and print its output? 如何在产品模型中调用方法并打印其输出?

Just add the function in your product model like: 只需在您的产品模型中添加功能,例如:

public function getStrippedFeatures()
{
    return your_stripping_method($this->features);
}

Fluid calls attributes with a prefixed get , so you only need this in the template: Fluid调用带有前缀get属性,因此您只需要在模板中使用此属性:

{product.strippedFeatures}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM