Is there a way to capture the field type in the template?

Say I have a wygwam field named {copy-seg} and I want to apply a class of wygwam to that container.




<div class="wygwam">{copy-seg}</div>

The field type data is not accessible in typical template tags, like {exp:channel}. Typically, you have to use the field names for your conditions, e.g.:

<div class="{if copy-seg}wygwam{if:else}{/if}">{copy-seg}</div>


{if copy_seg != ''}
<div class="wygwam">
  • yeah, that really isn't going to help too much though because I won't know what the field type is. – W3bGuy Nov 27 '13 at 18:22
  • 1
    How do you not know what the fieldtype is for a field? Do you change the types of existing fields often? – Jeremy Gimbel Nov 27 '13 at 18:37
  • No, I am trying to automate some things in templates. It was proving to be a little too complex, so I'm starting a new add-on now. I was hoping not to have to do that but it looks to be the best way. Then I can just wrap the template code in a tag pair and process it before it renders as needed. – W3bGuy Nov 27 '13 at 18:57

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.