Failed to find it in the docs.
Does D7 have page template suggestion functioning per content type? Or it requires a custom function?
Anyway, how can it be done?
Thanks.

Comments

konordo’s picture

This here will trigger page templates per content type like page-mycontentype.tpl.php in D6

In template.php:

function phptemplate_preprocess_page(&$vars, $hook) {
  if ($vars['node']->type != "") {
    $vars['template_files'][] = "page-" . $vars['node']->type;
  }
}

--------------------------------------------
Konordo Ltd
http://www.konordo.com

anni’s picture

Sorry, but You have to name Your file page-node-mycontenttype.tpl.php!!!

mertskeli’s picture

Thank you.
Unfortunately it won't work in D7 - theme suggestions were changed a lot.

LaurentAjdnik’s picture

mertskeli’s picture

Thank you. Will try it.

mertskeli’s picture

Yes, it works.

Nora McDougall’s picture

Thanks for the link. It was exactly what I needed.

imjameslarson’s picture

The example above didnt work for me, using $vars seemed to not work, replace it with $variables and it will work

function phptemplate_preprocess_page(&$variables, $hook) {
  if ($variables['node']->type != "") {
    $variables['template_files'][] = "page-" . $variables['node']->type;
  }
}
er.pushpinderrana’s picture

The example above didnt work for me, using $vars seemed to not work, replace it with $variables and it will work

With respect, It doesn't make any sense, you can use any variable name here either its $variables or $vars. Important thing is, most of time people forget to clear cache that required to reflect changes. I would suggest you check this with $vars as well and clear cache, it would definitely work.

Pushpinder Rana #pushpinderdrupal
Acquia Certified Drupal Expert