Drupal 6: How to create a new block region above / before comments section

While it is not hard to create a new block region in drupal 6, to create one before comments section
is not as easy to many people. I have managed to add a new block region above the comments, and moved the "similar term" block into it. You can see the result on this page. Here is how I did it:

1. Open clean.info ( clean is the theme name of the theme I use, open your theme-name.info under your theme directory )
below "engine = phptemplate", inset the following line:

regions[above_comments] = Above Comments

"Above Comments" is the name of the new region. Name it whatever you want.

Step 1 is no different from create a normal drupal region. Below is the tricky part:

2. open template.php, add the following code to the end:

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

note: replace the "clean" in clean_preprocess_node() with the theme name of yours.

3. open node.tpl.php, find the content section, mine is:

<?php print $content ?>

the content section of your theme's should look similar.

after this section, add:

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

4. flush caches, a new block region above comment section have been created.

Note: This region will not show in block list page with highlighted block, but you can assign content blocks to this region and it works fine.

22 Jan23:06

Thanks for this hack. It did

By virtualmcube (not verified)

Thanks for this hack. It did totally worked for me.
In this hack if you put that php snippet below

<?php print $content ?>

you will get the similar terms above the tags or the vocabulary you created. but i needed this similar terms below tags. so i made a little change by inserting the php snippet below

    <?php if ($taxonomy): ?>
      <?php print $terms ?>
    <?php endif;?>

in the above code the meta tag division is not showing, it should be completely below the meta tag division.
well, thought to add this if any-chance other users needed it
cheers!

Post new comment

The content of this field is kept private and will not be shown publicly.