phpdrupaldrupal-7drupal-theming

Better way to overide content page in drupal


I am creating custom content pages using this function in my template file

function myTheme_preprocess_page(&$var, $hook) {
  if (isset($var['node']->type)) {
    $var['theme_hook_suggestions'][] = 'page__' . $var['node']->type;
  }
}

Then I am creating a custom page--"content_name".tpl.php file for my content. However this also overrides the edit, moderate, track pages for that content as well. I only want it to override the main content page. Is there an easy way to do this.


Solution

  • Change your code to be something like:

    function myTheme_preprocess_page(&$var, $hook) {
      if (isset($var['node']->type) && is_null(arg(2))) { // the edited line
        $var['theme_hook_suggestions'][] = 'page__' . $var['node']->type;
      }
    }