Theming node view

Events happening in the community are now at Drupal community events on www.drupal.org.
You are viewing a wiki page. You are welcome to join the group and then edit it. Be bold!

There are times when you need to custom theme / design your node layout.
To do so, you will need to declare your theme, and assign #theme to the content array of the node.
Example:

<?php
[modulename]_view(...) {
...
$node->content["#theme"] = "mymodule_mynode";
}

[
modulename]_theme(...) {
return array(... ,
 
"mymodule_mynode" => array(
 
"template" => "mymodule-mynode",
 
"arguments" => array("node" => NULL)
);
?>

While to render the items in the theme, you may use "drupal_render" to render the theme.
<?php
echo drupal_render($node["title"]);
?>

Hope it helps those who need to know this :)

Drupal Developer Groups in Malaysia

Group organizers

Group notifications

This group offers an RSS feed. Or subscribe to these personalized, sitewide feeds:

Hot content this week