-->

in a TYPO3 6.1 fluid template, how to parse values

2019-08-11 07:49发布

问题:

I have built a small extbase extension with the extension builder in TYPO3 6.1.

One field is set up as "select". The extension builder set that up in the database as an int(11) field.

Values for that field are stored as 0,1

In the Backend, the labels can be configured in the TCA for each value.

But is there a simple way to do that for the fluid template as well?

I came around an "if" condition, but that can't be it, can it?

<f:if condition="{item.typ} == 0"><f:translate key="tx_stellenangebote_domain_model_item.unbefristet" /></f:if>
<f:if condition="{item.typ} == 1"><f:translate key="tx_stellenangebote_domain_model_item.befristet" /></f:if>

So how is this value being parsed properly in fluid?

回答1:

No, there is no simple way unless you define your "Stellenangebot" type as a true relation. But that would be an overkill. Apart from user's comment (you forgot the curly brackets) your solution is fine. I would consider using an if/then/else statement instead of two if statements.