Email
Share

We Rock Your Web Forum » Content Management Systems » Drupal

Drupal page template?

(2 posts)
  1. DrupalJunkie

    senior member
    Joined: Oct '09
    Posts: 77

    Is there a way to set a template file on the page level in Drupal? Ie. using page-content-type.tpl.php, in addition to page.tpl.php and page-front.tpl.php? I know I can do this on the node level, ie. node-content-type.tpl.php, but when I create a page level template it doesn't seem to have any effect.

    Posted 1 year ago #

  2. Posted 1 year ago
  3. cwd

    senior admin
    Joined: Jul '09
    Posts: 225

    Yes, you can. But you'll first need to add the following code snippet to your template.php file:

    <?php
    function themeName_preprocess_page(&$vars, $hook) {
      if (isset($vars['node'])) {
       $vars['template_files'][] = 'page-'. str_replace('_', '-', $vars['node']->type);
      }
    }
    ?>
    Posted 1 year ago #

RSS feed for this topic

Reply

(required)

Allowed markup: BBcode blockquote code em strong ul ol li font strike center u hr.
You can also put code in between backtick ( ` ) characters.