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
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!

25 May00:20
By Evelyn (not verified)

Hi,

Thanks for your tutorial! It's very much appreciated. I was just wondering how this can be done with custome node templates. Node-product.tpl.php for example?

I've tried using your method but instead of appearing in a distinct region above the comments it appears on top of the main content.

Any help at all is greatly appreciated!

17 Jun08:09
By alvin (not verified)

Thanks, this tip just helped me out. I already had a theme_preprocess_node function in my theme, but I just worked the line of code in that you show, and it worked great. Many thanks!

06 Jul14:49
By Anonymous (not verified)

This method work perfectly for my site running version 6.17.

Thank you very much.

28 Oct03:51
By trothatl (not verified)

Thanks! After spending over an hour trying to figure out how to do this on my own, I found your instructions. It took me less than five minutes and works perfectly!

28 Feb21:24
By M.E. Traylor (not verified)

Thanks so much! I know absolutely zilch about coding and I was able to follow these instructions successfully!

Post new comment

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