Posted By

sherakama on 10/23/08


Tagged

textmate node drupal theme pagetplphp BY


Versions (?)

Who likes this?

3 people have marked this snippet as a favorite

basicmagic
igama
esafwan


page.tpl.php theme by node type


 / Published in: PHP
 

  1. <?php
  2.  
  3. /**
  4. * This snippet loads up different page-type.tpl.php layout
  5. * files automatically. For use in a page.tpl.php file.
  6. *
  7. * This works with Drupal 4.5, 4.6, 4.7, 5, 6
  8. */
  9.  
  10. //if ($is_front) {/* check if it's the front page */
  11. // include 'page-front.tpl.php'; /*load a custom front-page.tpl.php */
  12. // return; }
  13.  
  14. if ($node->type == 'home_page') {
  15. include 'page-home_page.tpl.php';
  16. return; }
  17.  
  18. if ($node->type == 'web_page') {
  19. include 'page-web_page.tpl.php';
  20. return; }
  21.  
  22. include 'page-default.tpl.php'; /*if none of the above applies, load the page-default.tpl.php */
  23. return;
  24.  
  25. ?>

Report this snippet  

Comments

RSS Icon Subscribe to comments
Posted By: sherakama on October 23, 2008

This allows you to pull a different template page based on your node types. So in my theme folder I would have the following files.

node.tpl.php page.tpl.php -> this snippet page-homepage.tpl.php page-webpage.tpl.php and page-default.tpl.php

This is a pretty quick and easy way to theme different node types as well as for the home page.

Posted By: igama on August 14, 2009

Thanks ;)

Posted By: esafwan on November 28, 2010

thanks

You need to login to post a comment.