3

How to display block in node above comments. What i have tried is: create region - regions[above_comments] = Above comments after in template.php i have added this to THEME_preprocess_node

$variables['above_comments'] = theme('blocks', 'above_comments');

and in my node.tpl.php i have added this below print render($content);

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

Added my content to this region, but its still empty, dpm($variables['above_comments']) - - is empty. What is wrong?

3
  • Make sure commets are open for content type.
    – niksmac
    Commented Dec 6, 2012 at 10:10
  • Is this Drupal 6 or 7?
    – Clive
    Commented Dec 6, 2012 at 10:11
  • its drupal7 block, this block is open for my content type yep. Commented Dec 6, 2012 at 10:11

3 Answers 3

2

theme_blocks() was only available for Drupal 5 & 6, which is why your code isn't working.

The D7 equivalent is block_get_blocks_by_region(), e.g.:

$variables['above_comments'] = drupal_render(block_get_blocks_by_region('above_comments'));
0
0

If you are in 7: Commentsblock or even in 6: Comment block

Separate comment from node, then place your block above of comment block

1
  • thank you but i need to manage to do this without any modules. its possible, but i am not sure how to do it Commented Dec 6, 2012 at 10:13
-3

See node.tpl.php

Check where it prints <?php print render($content['comments']); ?>

Just render your region before <?php print render($content['comments']); ?>

1
  • You can't just render regions in node.tpl.php like that; at that point in the process, that template will have no clue what you're trying to reference. Clive's is the best answer. Commented Apr 15, 2016 at 19:52

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.