I want to create a custom template file based on the 'content type'. I have a content type named (machine name) : oldperson_profile
and I have created a file under the "templates" folder as page--oldperson_profile.php
. Now, based on the tutorials I found over Google, I did the following modifications in the template.php file:
function mytheme_preprocess_page(&$variables, $hook) {
if (isset($variables['node']->type)) {
$variables['theme_hook_suggestions'][] = 'page__' . $variables['node']->type;
}
}
Now I have cleared the cache and refresh the front end of the page, but nothing changed. I take the idea from https://www.digett.com/insights/overriding-page-templates-content-type-drupal-7 . Anything wrong I did?
Your template file name is wrong, change underscore _
to a dash '-' for your file name and also you are missing tpl
So it should be
page--oldperson-profile.tpl.php