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?

  • Make sure commets are open for content type. – niksmac Dec 6 '12 at 10:10
  • Is this Drupal 6 or 7? – Clive Dec 6 '12 at 10:11
  • its drupal7 block, this block is open for my content type yep. – Petro Popelyshko Dec 6 '12 at 10:11
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

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

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

  • thank you but i need to manage to do this without any modules. its possible, but i am not sure how to do it – Petro Popelyshko Dec 6 '12 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']); ?>

  • 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. – UnsettlingTrend Apr 15 '16 at 19:52

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.