0

I would like to know how to add to a template file a blog post content rendering code so that all blogs will be displayed whenever that template is rendered.

0

You can copy node.tpl.php and rename it to node--blog.tpl.php for any blog specific changes. Find more about Drupal Template changes

|improve this answer|||||
  • What I mean is that I have a template file let us say page--node--9.tpl.php and I want to add blog post code block to display blog posts. – Arsene Feb 25 '14 at 14:49
0

I'm confused about your question. But if you are trying to add a block of "related posts" or something like that, you need to create a view first, and then add it to a specific region.

Create a region from the .info file, e.g.:

regions[REGION_NAME] = REGION NAME

Then add this code to template.php file:

function THEME_NAME_preprocess_node(&$variables, $hook)
{
  $variables['REGION_NAME'] = theme('blocks', 'REGION_NAME');
}

Put this code into your node template file:

<?php if ($REGION_NAME): ?>
  <div class="REGION_NAME"><?php print $REGION_NAME?></div>
<?php endif; ?>

For detailed information see this post: In DRUPAL7, how to add a region in a node.tpl.php(node--contenttype.tpl.php)?

|improve this answer|||||
  • I did what you suggested. However the region did not appear in the list of region settings of the template for me to add a block. Please help. – Arsene Feb 26 '14 at 10:55
  • It is working now – Arsene Feb 26 '14 at 14:36

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