Friday

Drupal7: Hide and print contents and fields in "node.tpl.php"

Drupal defines the content as An array of node items($content). You can print all the array elements using render($content)  or print a subset as render($content['field_example'])


To print a subset of the elements, first hide this element:
hide($content['field_example'])  



then print it in the place you want:
render($content['field_example']).


This feature is very important in many cases. 


1.If you open file: node.tpl.php in your theme,
 you can see that drupal uses this manner to hide comments and links and print them in the bottom of the page.


2.other example, you may need to hide a field as body:
hide($content['body']);


and add your custom update to it before printing.

$text=render($content['body']);
update $text and print it later.


3.A third example is hiding several things: fields, groups and modules:



hide($content['body']);
hide($content['addtoany']);
hide($content['field_subtitle']);
hide($content['group_imag_group']);


then update and print them in a specific order.







for more information about "node.tpl.php"...