Olle Härstedt
Olle Härstedt

Reputation: 4020

How to access TCA-fields in the Fluid template for a custom content element

I've created a custom content element called cat_but (category button). I've added TCA and content element wizard without problem. The category button have only one field: sys_category. Exactly one category should be selected. From this, I want to render a link action to a controller using that category as argument. But how would I access the sys_category field from the Fluid template for the content element? There is no PHP class associated to the element, no? Or can I fetch sys_category from Typoscript? Or could I access the tt_content from a view helper?

Edit: Possibly feed {data.uid} to view-helper and from there look up categories.

Upvotes: 0

Views: 927

Answers (1)

Charles Brunet
Charles Brunet

Reputation: 23110

If you name your element settings.sys_category, then you should be able to access its value with {settings.sys_category} in the Fluid template, as well as from $settings['sys_category'] in the Controller.

Otherwise, you will need to parse the pi1_flexform field of your content element. In Fluid, it could be done using a custom ViewHelper, or using some ViewHelpers provided by the vhs extension.

Upvotes: 1

Related Questions