简体   繁体   中英

cannot get drupal 7 to recognize a page template for a content type

I have a drupal 7 site that I want to make secondary front pages on. the problem with this is the "page--front.tpl.php" is a two column layout and the "page.tpl.php" is a one column layout. if i use a node template it shoves it in the body of the one column.

the theme name is "egress" the machine name for the content type is "landing" but when i try to hook the page--landing the same way i do the node--landing nothing happens. nothing.

i am clearing the cache and hard refreshing the page with every change of the template files.

one code i have tried in the of the "page.tpl.php"

function egress_preprocess_page(&$vars) {
    global $node;
    if ($node->type == 'landing') {
        $vars['theme_hook_suggestions'] = array('page__landing'); 
    }
}

another

function egress_preprocess_page(&$vars) { 
    if ($vars['node']->type == "landing_page") {
        $vars['template_files'][] = 'page--landing';
    }
}

anyone ideas?

The following should go to your theme's template.php rather than page.tpl.php

function egress_preprocess_page(&$vars) {
    // For page--(node-type).tpl.php
    if (isset($vars['node'])) {
        $vars['theme_hook_suggestions'][] = 'page__'. $vars['node']->type;
    }

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