简体   繁体   中英

Theming node by content type in Drupal 7

I am building a drupal theme from scratch and I encountered a problem - when trying to theme a node by content type <?php print render($content) ; ?> gives me nothing. My template.php file:

<?php
function etalonestate_preprocess_page(&$vars) {
    if (isset($vars['node']->type)) {
        $vars['theme_hook_suggestions'][] = 'page__' . $vars['node']->type;
    }
}
?>

Thanks in advance :)

In your tpl file, where you want to render($content) you have to put near first lines:

hook_preprocess_page();

Hope this helps.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM