Alternatives to "Comment block" for moving comments

We encourage users to post events happening in the community to the community events group on https://www.drupal.org.
morisy's picture

I feel like this should be a basic bit, but I cannot for the life of me figure out how to move comments around in a theme.

Comment Block does essentially what I want, but I'd rather due it in the theme and on a per-node-type basis, rather than across the site and via blocks.

Is it in node.tpl.php? Tried Googling around but still couldn't find anything.

Comments

Can you explain what you mean

matt.lutze's picture

Can you explain what you mean by "per-node-type basis"? Are you looking to change the location of the comments in a specific content type, or for specific nodes (but not all nodes)?

I'm also curious what use cases you developed that result in displaying comments differently across the site.

Without more info, I'd suggest setting up a few variants in Panels 3 (http://drupal.org/project/panels), plus setting up a taxonomy for contexts to determine which variant to display.

Hi Matt, Thanks for the

morisy's picture

Hi Matt,

Thanks for the response. I'm looking to change where comments show up on a "per-node-type" basis. In our use case, we have a node type "news" for "news articles" and "vendor" for profiles of our vendors.

I want news article comments to show up below that, but for the comments on our vendors to show up next to the vendor profiles, along with information like where they work:
http://sparechangenews.net/vendor/peaches

In the second use case, the comment section will be a comment section/lightweight blog.

I thought this would be included directly in one of the theme templates, but can't find where comments are actually called in on node.tpl.php. I've used Panels 3 but would like to avoid it in this case for simplicity's sake, but if that's not possible it's a good idea.

Web guy, SpareChangeNews.net
Twitter: @morisy / @sparechangenews

I see. The confusion I had

matt.lutze's picture

I see. The confusion I had was a result of both hyphens; so, per Node Type, you'd like the display to be different.

So, yeah I'd really suggest running the display through Panels. Actually from simplicity's sake, having two node variants--News and Vendor--and being able to configure them through the UI will be easier than customizing the tpl and css. The panel variants will be super-easy to build, actually, as all you'll need to do is set them to display based on content type when you initially build them.

Plus, using a panel for display gives you "opt-in" control over the content shown, which forces a best-practices moment and makes you explicitly choose what parts of the node are displayed (and where). By forcing conscious rhetorical construction, you'll improve the overall experience for the user.

So, yeah, I'd use one of the two-column layouts and assign the node body to the one side, and the comments to the other.

Thanks Matt, I'll give it a

morisy's picture

Thanks Matt, I'll give it a look see.

Web guy, SpareChangeNews.net
Twitter: @morisy / @sparechangenews

Changing location of Comments, without panels

kanani's picture

So if I didn't want to use panels, any thoughts on how to explicitly control the location of comments via the template files?

Hi, any news on this ?

doomed's picture

Hi, any news on this ?

node-TYPE.tpl.php

yelvington's picture

Override the node.tpl.php file.

Rather than printing the $content variable, explicitly print out your $node fields. The dev module can help you identify them accurately.

Print out the comments using comment_render($node->nid, 0); note that this should be conditional on the value of $page.

All of this assumes D6. Quite a few changes in D7.

any solution for D7?

enxox's picture

Hi all,
I'm googling a lot without finding a solution to put the comment interface in a block for 7.

All I want to do is to put the comment part under other blocks or views, with a structure like this

  • node
  • other block(s) (views)
  • comment interface

I can't find a working solution for drupal 7, rewriting node.tpl.php doesn't seem to me the right solution because I have different kind of nodes.

Panels seems to me a too-complex module for this purpose.

Any ideas?

consider

zkrebs's picture

Using the Context module - it lets you put blocks in regions depending on circumstances (node types, paths, vocab, etc.) http://drupal.org/project/context

but...

enxox's picture

comment is not a block, so I can't move it... or not?

my bad

zkrebs's picture

I was assuming you were going to use comment block! If that's not what you want, then you'll have to edit some tpl.php files.

comment block

enxox's picture

comment block is not for D7

take a look

re: enxox

deborra's picture

Setting node comments after all blocks on a page was what I also needed to do for Drupal 7. I tried the comments block but it did not look as nice, and I have a module for reordering comments enabled and did not want to deal with any unforeseen interactions, so I dropped that effort. Instead, reading around it looked like updating the templates might do the trick. One caveat, my nodes are all simple and comments for all content types are placed at the end of the content section defined by my theme. I disabled the printing out of comments at the end of node.tpl.php, and added the following code just after the section that renders the content section ($page['content']) in page.tpl.php:

<?php
if (isset($page['content']['system_main']['nodes'])):
   
$nodes $page['content']['system_main']['nodes'];
   
$nids = array_keys($nodes);
   
$nid = $nids[0];
   
$comments $page['content']['system_main']['nodes'][$nid]['comments'];
   
$links $page['content']['system_main']['nodes'][$nid]['links'];
?>

<?php
if ($links):
?>

<?php
print render($links);
?>

<?php
endif;
?>

<?php
print render($comments);
?>

<?php
endif;
?>

Would very much appreciate any comments as to if I'm shooting myself in the foot. I've basically simply jumped into the framework/WebStack and have not been able to talk with folks re: best practices etc.

PS. I do not know why the printout of the code is so fragmented. It is one code block.

Newspapers on Drupal

Group organizers

Group categories

Topics - Newspaper on Drupal

Group notifications

This group offers an RSS feed. Or subscribe to these personalized, sitewide feeds:

Hot content this week