2

I have set my node field to 'Hidden' in the Manage Display page, and am printing the field in the corresponding tpl.php file, but the field only prints if I set the field format to 'Default' in Manage Display.

How can I hide the node field, and JUST print it in the template?

This is the code I'm using to print the field

<?php print render($content['field_description']); ?>

so basically what's happening... is that if I set the format to 'Hidden' in Manage Display, the field doesn't display at all, and then if I set the format to 'Default', the field shows twice - once where I've printed it using the above code, and again in the content area.

What am I doing wrong?

Cache has also been cleared.

1 Answer 1

2

Your template file will only print fields that are not hidden in the Manage Display window, so you definitely need to make it 'default'.

It's probably printing twice because you have the default print render($content); somewhere in your template file.

If you want to print the field separately and not have it print when the main content is printed you need to hide the field in the template file not in Manage Display:

<?php hide($content['field_description']) ?>

Make sure you do this early in the file, before print render($content);.

1
  • I still had print render($content); in the template file! Thanks Darvanen, that fixed it for me. :)
    – caustic
    Commented Mar 11, 2015 at 23:50

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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