Skip to content

Instantly share code, notes, and snippets.

@ForestMars
Last active December 25, 2015 23:59
Show Gist options
  • Select an option

  • Save ForestMars/7060710 to your computer and use it in GitHub Desktop.

Select an option

Save ForestMars/7060710 to your computer and use it in GitHub Desktop.
Theme suggestion for node type.
function newtheme_preprocess_page(&$vars, $hook) {
if (isset($vars['node'])) {
// If the node type is "blog" the template suggestion will be "page--blog.tpl.php".
$vars['theme_hook_suggestions'][] = 'page__'. str_replace('_', '--', $vars['node']->type);
}
}
// Add a single suggestion for nodes that have the "Promoted to front page" box checked.
function newtheme_preprocess_node(&$variables) {
if ($variables['promote']) {
// looks for node--promoted.tpl.php in your theme directory
$variables['theme_hook_suggestion'] = 'node__promoted';
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment