Custom page template creation

appetals's picture
appetals
Mon, 02/01/2016 - 07:13
#1
Custom page template creation

Hi ,

I need to create custome page for node for which i have added below code inside my subtheme template.php

function md_make_subtheme_preprocess_page(&$variables) {
if (isset($variables['node']->type)) {
    echo 'page__' . $variables['node']->type;
    // If the content type's machine name is "my_machine_name" the file
    // name will be "page--my-machine-name.tpl.php".
    $variables['md_make_subtheme_hook_suggestions'][] = 'page__' . $variables['node']->type;
  }
}

and inside my subtheme/templet/node new file created as  page--bride_testimonial.tpl.php        

But the new template file is not getting called. Am i missing any code lines.    

phuonght's picture
phuonght
Mon, 02/01/2016 - 21:55

Hi,

Please edit file name from page--bride_testimonial.tpl.php to page--bride-testimonial.tpl.php.

phuonght's picture
phuonght
Tue, 02/02/2016 - 02:22

Placing file in subtheme/templet/node is ok. Please note that subtheme must be actived. 

phuonght's picture
phuonght
Tue, 02/02/2016 - 23:00

We checked and could see your structure of suggestion was wrong. Also, our Md Make theme has function Hook suggestion in theme for page content type already. You could take a look at file page.preprocess.inc (sites\all\themes\md_make\theme_setting\front ), line 23:

//Hook suggestion
if (isset($vars['node'])) {
$vars['theme_hook_suggestions'][] = 'page__node__type__' . $vars['node']->type;
}

=> in subtheme, if you would like to create template for page of content type so please folloư file page--node--type--bride-testimonial.tpl.php that our developer created in folder sites/all/themes/md_make_subtheme/templates/page

Demo : /node/175

Log in or register to post comments
Have More Idea?

We are here to build your website!

No Universal solution fits all special business requirements. Our experienced team is ready with ideas and state-of-the-art technical solutions to consult the best solution within your budget.