简体   繁体   中英

Drupal 7 new custom template

Our drupal developer left company, so now I'm learning it )

If I open any page editor in admin panel, I see 'custom template' selectbox. In file structure I have some page-- and node-- files with similar names. For example in select box there is item 'Full width template'. And there are node--custom--fullwidth.tpl.php and page--custom--fullwidth.tpl.php in file structure.

So I need to create one more custom template but I can't find it in admin panel. How to do it, tell me please.

Thanx!

I found it myself. Go to structure-content types-manage fields. There is a field - 'CUSTOM template'. There I need to add new one.

Try to write this piece of code in your template.php file.

function yourthemename_preprocess_page(&$vars, $hook) {
    if (!empty($vars['node']) && !empty($vars['node']->type)) {
        $vars['theme_hook_suggestions'][] = 'page__node__' . $vars['node']->type;
    }
}

And then create the new custom template in side /sites/all/[theme]. And then clear the cache once.

I have tried it in Drupal 7.x and its working fine for me.

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