0

What is the best way to don't show up a field if it is not filled in.

I have a content-type for the homepage: (Machine name: home_pagina).

There is a field for my client to give a warning-message if necessary: (Machine name: field_aandachts_tekst).

The warning message has to show up in a colored box/div. But if the field is not filled in, the box/div should not show up.

I tried to achieve this with a field-template....

I already have a "field.tpl.php" created. So i thought if a create a special field template for the field (field_aandachts_tekst) i could put the colored box/div in there. And if the field is not filled in the box/div would not show up also.

But it seems that the field-template for the (field_aandachts_tekst) is not used...

My template for controlling the view of the (field_aandachts_tekst) is called:

field--field-aandachts-tekst.php

but it seems this template is not used... (instead it uses: "field.tpl.php")

The code in my "node--home_pagina.tpl.php" looks like this:

print render($content['field_aandachts_tekst']); surrounded with php-tag ofcourse

Any tips or suggestions are good!

Thanks, Kristof

0

Okay dear readers,

I find the solution/problem:

I forgot the extension .tpl in my template name. Stupid of me. Everything is working fine now.

Thanks for reading!

kristof

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.