1

How do I go about overriding the default template for content of the blog page (the index page that shows the blog teasers)?

Also I would like the original template code for this content so that I can rewrite my content effectively, is the .tpl.php somewhere within drupal core, that I could copy out into my theme?

Thanks for your time!

5

I don't think there is separate file for Blog content type. Because for Blog default node.tpl.php is called. If you want to create tpl file for blog, straight away copy file from node.tpl.php and create a tpl like node--blog.tpl.php.

And if you want to create page tpl for blog content type then you can create

page--blog.tpl.php

And you have to add some PHP code in template.php file in THEMENAME_preprocess_page() function

if( !empty($vars['node'])){
    $vars['theme_hook_suggestions'][] = 'page__'. $vars['node']->type;
  }
4
  • To target the index blog page you have to create page tpl for that. Just see the path and create a page template file according to path. Because in Drupal we can also create tpl according to path. – mohit_rocks Sep 15 '12 at 4:53
  • node--blog.tpl.php works great. page--blog.tpl.php works great for the individual blog entries but it doesn't seem to target the index blog page that shows all the summaries. Any idea how to do that? – Scott Lawrence Sep 15 '12 at 4:53
  • So how do I target in that way? What should the filename of my template be called if URL is /blog? – Scott Lawrence Sep 15 '12 at 4:56
  • If there is user/login then we can create tpl file like page--user--login.tpl.php. You can apply same concept in blog listing page also. – mohit_rocks Sep 15 '12 at 4:56
1

I think, we don't need any php code in template.php file for create blog template file. The files only enough for it ( I mean node--blog.tpl.php and page--blog.tpl.php ) After created the file clear your cache, then your new template will be worked.

0

The best and fast option is use views, and in the views page url add the blog paths.

With views + semantic views + display suit you can rebuild the html of your site without change no one *.tpl.php

Oskar

0

Creating a node--blog.tpl.php and adding the following to the code worked for me.

<h2>
  <?php print render($title_prefix); ?>
  <?php print render($title); ?>
  <?php print render($title_suffix); ?>
</h2>

I didn't need to add the preprocess function.

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.