3

I am trying to create a custom layout for my blog listing and blog content display pages.

The following url will display all the latest blogs based on the conditions that I have set.

http:///general-blog

When I click on the 'Read more' button corresponding to a button, it will display the full blog contents in another page.

Sample format : http:///general-blog/tourist-details

I am able to modify the layout of the page corresponding to blog listing. For this, I have created a custom tpl file : page--general-blog.tpl.php.

What I want is to create a new template file for displaying the contents of individual blogs.

The individual blog content display page is not entering - page--general-blog.tpl.php file. It's always using the template - page.tpl.php.

I tried creating separate tpl files like :

page--general-blog--%.tpl.php

But, the changes in this template is not getting effect in the individual blog content display page.

How should I move forward. Has someone had any similar situations?

  • did you flush the cache? it's a very important step! otherwise your new template file won't be recognized. – No Sssweat Nov 13 '15 at 12:58
0

Declare your template using 'theme_suggestion` in your page preprocess function. like the following:

function THEMENAME_preprocess_page(&$vars){
  // Page template suggestion based on node type
  if (!empty($vars['node'])) {
    $node_type = $vars['node']->type;
    $vars['theme_hook_suggestions'][] = 'page__node__' . $node_type;
  }
}

if your node type is blog then your template will page--node--blog.tpl.php Don't forget to clear cache after adding this code and your tpl file

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.