I would like to add a title to my news feed. I have tried to edit node--teaser.tpl.php and added

<?php if($page['feed-title']): ?>
<!-- start feed title -->
<?php print render($page['feed-title']); ?>
<!-- end feed title -->
<?php endif; ?>

on top, then I added

regions[feed-title] = Feed Title

in my theme.info file. I created a block which is assigned to this region but still, nothing is being displayed, why not? Am I doing something wrong or can I not add regions into a region template file?



If you look at the page.tpl.php template file used by the Bartik module, you will notice it uses code like the following to render a region.

  <?php if ($page['triptych_first'] || $page['triptych_middle'] || $page['triptych_last']): ?>
    <div id="triptych-wrapper"><div id="triptych" class="clearfix">
      <?php print render($page['triptych_first']); ?>
      <?php print render($page['triptych_middle']); ?>
      <?php print render($page['triptych_last']); ?>
    </div></div> <!-- /#triptych, /#triptych-wrapper -->
  <?php endif; ?>

node--teaser.tpl.php is not used to render a page, but a node into a page. It is hierarchic, someway: html.tpl.php wraps the content of page.tpl.php, which wraps the content of node.tpl.php.
Regions are part of a page, not a node; therefore, the template file where to render the regions is page.tpl.php or any suggested templates used instead of that one.

| improve this answer | |

When you add a region in theme.info file, you have to render the region in page.tpl.php.

That's where you are doing wrong. You are doing it in node.tpl.php.

Don't forget to clear the cache after you render your region in page.tpl.php.

| improve this answer | |
  • Can somebody explain the reason of negative vote here ? – RajeevK Aug 5 '13 at 17:29

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.