I created a new content type with several fields in it. How would I print out those fields anywhere on the page that I need them like in the sidebar and other areas? What is the syntax for printing out a field? Also, I think I have to name a PHP file after the content type. What do I name it in Drupal 7?

  • I guess the question is about the name to use for template files. – kiamlaluno May 3 '11 at 20:08

This is best accomplished with Render Arrays. Please read Theming Node Form into Regions for a tutorial.


I think the question is how to put fields from a node to the page itself. You have to use hook_page_alter() and you can do something like this:

$page['sidebar_first']['node_links']=$page['content']['system_main']['nodes'][$nid]['links']; for putting node links in the sidebar.

For a field from a node you can do something like this: $page['sidebar_first']['test_block']=$page['content']['system_main']['nodes'][$nid]['field_your_field'];

Note: $nid si the desired nid from the $page['content']['system_main']['nodes'] array. The idea is that you can modify anything that a region contains and you can easily create blocks in any region with this hook.


I think you should install the devel module and do a


You'll be able to see all the data contained in the node and therefore, you'll be able to use them as you want.

  • I installed the Devel Module and put in <?php echo dpm($node); ?> – Jordash May 6 '11 at 2:36
  • And nothing happened.. Any ideas? – Jordash May 6 '11 at 2:36

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.