Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

typo3

fluid

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. 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?

like image 270
t3o Avatar asked Dec 28 '25 05:12

t3o


1 Answers

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:

{product.strippedFeatures}
like image 198
Thomas Löffler Avatar answered Dec 30 '25 23:12

Thomas Löffler



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!