My client wants a comment section on the front page only. I can't figure out how to allow commenting on the front page. I tried allowing commenting on basic pages, but it wont show on the front.


  • Hello, and welcome to Drupal Answers. Do you mean to allow users to comment on nodes shown in the front page, from the front page? – kiamlaluno Dec 24 '12 at 20:17
  • I thinks it shows the comment on front page. – Sumit Madan Dec 25 '12 at 9:56
  • @kiamlaluno No, you know how you can allow commenting on pages? Well how can I allow it for the home page? – Migdesigns Dec 26 '12 at 20:14

Excerpt from modules/comment/comment.module inside function comment_node_view($node, $view_mode):

// Only append comments when we are building a node on its own node detail
// page. We compare $node and $page_node to ensure that comments are not
// appended to other nodes shown on the page, for example a node_reference
// displayed in 'full' view mode within another node.
if ($node->comment && $view_mode == 'full' && node_is_page($node) && empty($node->in_preview)) {
  $node->content['comments'] = comment_node_page_additions($node);
  1. commenting for the node must be turned on
  2. The node must be shown in the full-view_mode (normally this is node/<nid>)
  3. node_is_page(): Whether the current page is the full page view of the passed-in node.
  4. It must not be an edited preview of this node.

If you still feel like showing the comments on the frontpage for a specific node, try this:

$frontpage_commenting_node = node_load( **1** );
print render(comment_node_page_additions($frontpage_commenting_node));

Note: - You need to change the parameter of node_load to the effective node id in your system. - This is for Drupal 7

| improve this answer | |
  • This is not working. I tried putting the code in page--front.tpl.php and it spits out errors. – Migdesigns Dec 31 '12 at 20:31

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.