I am using Drupal 7 I have a content type courses. I have a page folder in template folder, with courses.tpl.php file. When i go to courses page it is showing contents from courses.tpl.php. Issues is that courses.tpl.php is not rendering blocks.

I checked region in info file. I cleared cache etc, but block is not rendering. I am not sure, if this page is a taxonomy page. 'footer_testimonials' is the block i am trying to render in this page, but it is not showing up.

'footer_testimonials' is showing up in page.tpl.php but not in courses.tpl.php

<div id="innerCourse_area">
    <div id="searchbox">
    <?php print drupal_render(drupal_get_form('course_searchbox'));?>
    <div id="innerTopRight_info"><?php print $page['page']['course_page_top_ad']['block_1']['#markup'];?></div>
    <div class="clearfix"></div>
    <h4>Popular Courses: <em>Certificate IV in Bookkeeping, Diploma of Accounting, Diploma of Business, Advanced Diploma of Accounting</em></h4>

</div><!--end inner course area-->
<div class="innerRightCol">
<div class="contentInfo">
    Central College Distance Education offers a range of Government and Industry Accredited courses ready to help launch your career.  Remember, Central College has been launching careers for over 30 years.  You may also be interested in our specialty Central College Certificates that will help you better manage your existing business and do it in your own time at your own pace, right in the comfort of your home.


//$taxoTerm = course::get_taxonomy_term(1);
$categories = course::getAllCategories();

foreach($categories as $category):?>
    <div class="course_cats">
        <div class="taxo_term"><h3><?php echo $category->name;?> Courses</h3></div>
        <div class="taxo_courses">
            <?php //get courses by taxonomy
                $courses_term = course::courses_by_term($category->tid);
                $i = 0;
                foreach($courses_term as $course):
                $courseObj = course::getCourseByNid($course->nid);
                <li><a href="<?php echo course::courseUrl_alias($course->nid);;?>"><?php echo $courseObj->title;?></a></li>
                <?php endforeach;?>
    echo '<div class="clearfix"></div>';

<div class="clearfix"></div>
</div><!--end innerRightCol-->

<div class="innerLeftCol">
<?php print render($page['footer_testimonials']);?>
</div><!--end innerLeftCol-->
  • Are you using module_invoke?
    – Sathiya
    Commented Dec 19, 2012 at 10:26
  • 1
    Hello, and welcome to Drupal Answers. May you show the code you are using? Without that, it is not possible to answer about what is wrong in your code.
    – apaderno
    Commented Dec 19, 2012 at 10:28
  • @kiamlaluno : added code of the page into question. Commented Dec 19, 2012 at 10:33
  • @Sathiya: not using module_invoke Commented Dec 19, 2012 at 10:34
  • That is perfect. Is that the code for courses.tpl.php?
    – apaderno
    Commented Dec 19, 2012 at 10:38

1 Answer 1


A page.tpl.php template file doesn't get blocks to render; it gets the theme regions to render, which by default are the following ones:

  • $page['help']: Dynamic help text, mostly for admin pages
  • $page['highlighted']: Items for the highlighted content region
  • $page['content']: The main content of the current page
  • $page['sidebar_first']: Items for the first sidebar
  • $page['sidebar_second']: Items for the second sidebar
  • $page['header']: Items for the header region
  • $page['footer']: Items for the footer region

Themes can define other regions as well.

When you want to show a blocks that has been associated to the "highlighted" region, the page template file needs to contain the following code (or similar).

<?php if ($page['highlighted']): ?><div id="highlighted"><?php print render($page['highlighted']); ?></div><?php endif; ?>

Without that code, a block that should visible in the "highlighted" region would not be visible.

In a taxonomy term template file, you need to get the block content using code similar to the following one.

  global $theme_key;

  $query = db_select('block', 'b');
  $block = $query
    ->condition('b.theme', $theme_key)
    ->condition('b.status', 1)
    ->condition('b.delta', $delta)
    ->condition('b.module', $module)

  if ($block) {
    $array = module_invoke($block->module, 'block_view', $block->delta);
    drupal_alter(array('block_view', "block_view_{$block->module}_{$block->delta}"), $array, $block);

    if (isset($array) && is_array($array)) {
      foreach ($array as $k => $v) {
        $block->$k = $v;

    if (isset($block->content) && $block->content) {
      // Normalize to the drupal_render() structure.
      if (is_string($block->content)) {
        $block->content = array('#markup' => $block->content);

      print render($block->content);

You need to know the module implementing the block, and the delta used for that block. It is better to put the code in the preprocess function to set a variable that is then rendered in the template file. As usual, the logic code should be in the template.php file of the theme, or in the module file, and the rendering code in the template file. (Don't confuse the template.php file with the template file.)

Instead of executing that code, it is easier to assign the block you want to show in the taxonomy term page to taxonomy term pages. In the settings page for the block (admin/structure/block/manage/<block id>/form/configure) select Only the listed pages, and in the textarea enter:



  • courses.tpl.php is a taxonomy page template. I tried your suggestion and did not work. Do you know, how to render block in a taxonomy page template. Commented Dec 19, 2012 at 11:00

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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