I have created a block and I don't want it to display until there are a number of comments posted on the node because if I just display the block the site will look ugly.

How would I go on to make it that when the node has lets say 6 comments the block or some content will show but when the node has less than 6 comments the block wont show.

2 Answers 2


use php code for your block "Show block on specific pages" fieldset settings, paste next code:

if (arg(0) == 'node') {
  $node = node_load(arg(1));
  if ($node) {
    return $node->comment_count > 5;
return FALSE;

p.s. Enable PHP filter module, if you not see PHP code option.


If you are making the block using Views, you should be able to do this pretty easily by adding a view filter of "Content: Comment Count" is greater than or equal to "6"

It will then only show the block when it has results that meet your criteria.

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.