2017-04-26 41 views
1

我有這樣一行模板:如何在TYPO3流體模板中調用實體方法?

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

其中「功能」就是「產品」的數據模型的屬性。

我想打印結果,而不是調用產品的方法。例如:

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

但是,這給了我空的內容。

如何在產品模型中調用方法並打印其輸出?

回答

3

只需添加功能在您的產品型號,如:

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

流體電話與前綴get屬性,所以你只需要這個模板:

{product.strippedFeatures} 
+0

流體看起來也爲前綴'是'和'擁有'。 – Daniel

+0

流體使用「get」前綴調用屬性的部分完成了這個訣竅 - **謝謝!我想添加一個視圖幫助器,但現在正在工作。 ViewHelper:(http://stackoverflow.com/questions/24612883/how-to-access-a-method-and-pass-an-argument-within-the-template) – t3o

+0

呃我太遲了^^ –