Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
By businessmedia on
Hello!
I'm building very specific theme and need to apply custom HTML markup + CCS to almost all elements on page(title, user picture, display of taxonomy and so on...).
What I exactly need is to modify layout, which goes in $content variable.
So the question is what function is used for building $content and is it possible to override it ?
Comments
It depends on which template
It depends on which template file you are talking about. In page.tpl.php $content represents the contents of the page associated with the current path. For example if the path is of the form node/{nid} (ex: node/32) $content is controlled by node.tpl.php
To be more precise: $content
To be more precise: $content is printed in node.tpl.php, but the value is generated in the node_view() function (http://api.drupal.org/api/function/node_view/6) and passed on to node.tpl.php as $content by template_preprocess_node() (http://api.drupal.org/api/function/template_preprocess_node/6).
If you want to adjust the way the content of a node is printed (assuming that you use CCK), you can:
1) see if the 'display fields' tab at /admin/content/node-type/[nodetype]/display gives you enough control
2) construct your own output in node.tpl.php (or node-[nodetype].tpl.php) using the variables and the $node object
3) use the contemplate module, which alters the $content variable before it is sent to node.tpl.php