Hi peeps,

I've got a layout in which content of the CCK node is displayed in one column and comments are displayed in the other column parallelly to the content. That's the layout idea, but I can't achieve it. I made a custom node-content_my_article.tpl.php which prints only node title and node terms. But I still can post comments under the content. I didn't print $links but the damn comments (and 'comment or login' links too) keep appearing :((((

Anyone, pls help! :(((

Comments

pielgrzym’s picture

Could someone at least tell me how to catch comments before they are glued to the end of content? It's far the dumbest idea to make the whole comments page be sticked to the end of content without the ability to print it wherever we want :(( aaargh. so frustrated :[

--
Pielgrzym

pielgrzym’s picture

Thanks to helpfull people from drupal-support irc channel we figoured out a way to move comments:

It's for Drupal 4.7.x:

function mytheme_comment($comment, $links = array()) { 
  our_comment($comment, $links);
  return '';
}
 
function our_comment($comment = array(), $links = array()) { 
  static $output = '';
  if (!empty($comment)) {
    $output  = '<div class="comment'. ($comment->status == COMMENT_NOT_PUBLISHED ? ' comment-unpublished' : '') .'">'; 
    $output .= '<div class="subject">'. l($comment->subject, $_GET['q'], NULL, NULL, "comment-$comment->cid") . ' ' . theme('mark', $comment->new) ."</div>\n"; 
    $output .= '<div class="credit">'. t('by %a on %b', array('%a' => theme('username', $comment), '%b' => format_date($comment->timestamp))) ."</div>\n"; 
    $output .= '<div class="body">'. $comment->comment .'</div>'; 
    $output .= '<div class="links">'. theme('links', $links) .'</div>'; 
    $output .= '</div>'; 
    return $output; 
  }
  else {
    return $output; 
  }
}

Then we simply invoke our_comment() wherever we want in out theme :)

It actually catches the data passed to theme function and prints it out somewhere in the theme using an exact function copy. The only problem is the damn comment form. The comment form still appears under the node. I tried overriding mythem_comment_form the same way, but didn't succeed.

I beg for some help ;)

--
Pielgrzym

brenda003’s picture

I'm trying to get this to work on 5.1 but it isn't working correctly...

Will post my solution once I get it.

n8tron’s picture

Looking in to how to solve this.

anonymouscowards’s picture

Maybe the easiest way is to try and use CSS and position:absolute etc to seperate the main node from the comments rather than php.

kabaman’s picture

i dont believe this
this messes up my complete template design
i need to place the comments into a certain div
there is always a variable for everything like $titles $messages $missions etc.
WHY not for COMMENTS

dvessel’s picture

Here ya go. Simplified. Scrap your previous code and place inside template.php.

function phptemplate_comment_wrapper($content = '', $type = 'comments') {
  // Cache values with these static variables.
  // Will fill when $content has value and $type is 'comments' --default.
  static $all_comments;
  // Will fill when $content has value and $type is 'form'.
  static $comment_form;
  
  // Default output.
  $output = '';
  
  // if $content has a value then fill static variables depending on $type.
  // else fill $output to return below.
  if (!empty($content)) {
    if ($type == 'comments') {
      $all_comments = $content;
    }
    elseif ($type == 'form') {
      $comment_form = $content;
    }
  }
  else {
    if (isset($all_comments)) {
      $output .= $all_comments;
    }
    if (isset($comment_form)) {
      $output .= $comment_form;
    }
  }
  
  // Double check $output before returning the surrounding markup.
  if (!empty($output)) {
    return '<div id="comments">'. $output .'</div>';
  }
}
function phptemplate_comment_form($form) {
  // returns nothing. Just intercept and let comment wrapper handle output.
  theme('comment_wrapper', drupal_render($form), 'form');
}

After that, all you need to call is theme('comment_wrapper'). Assign it to a variable or print directly from node.tpl.php or page.tpl.php. Haven't tested. It should do though.

Good luck.

edit:: Oh, and this is for Drupal 5. Don't think there's a wrapper function in 4.7 but you get the idea. You should be able to make up a similar function.

kabaman’s picture

thank you very much

the "redirect" of the comments works
but the comment form is now shown twice
once below the nodecontent and once below the redirected comments
but only the submit-button of the first form works

any idea how to fix this ?

dvessel’s picture

Yeah, I see. It's do to how the comment form is called up and unfortunately it runs through theme_box() which is a very general theme function. I tried messing with it but there's no way to get the context reliably. An alternative would be to go through the comment administration page and set the comment form to output under the comments instead of on a separate page.

After that, you can simplify the function down to this:


function phptemplate_comment_wrapper($content = '') {
  // Cache values with these static variables.
  static $all_comments;

  // Default output.
  $output = '';
  
  // if $content has a value then fill static variable.
  // else fill $output to return below.
  if (!empty($content)) {
    $all_comments = $content;
  }
  elseif (isset($all_comments)) {
    $output .= $all_comments;
  }
  
  // Double check $output before returning the surrounding markup.
  if (!empty($output)) {
    return '<div id="comments">'. $output .'</div>';
  }
}

I don't think anything else can be done about it from the theming end. If it bothers anyone, your free to create an issue. Search first though. :)

kabaman’s picture

thanks a lot for your help

i created as you suggested a issue http://drupal.org/node/161139 but didnt get any respond yet
the last days i tried to catch with an adapted version of your code the comment forms and place them were i want them to be

function mytheme_box($title = '', $content = '', $region = 'main') {
  // variable to save form
  static $comment_form;
  // Default output.
  $output = '';
  // try to catch the comment form by its titles or url
  if($title == 'Post new comment' || $title == 'Reply' || $title == 'Edit comment' || (arg(0) == 'comment' && arg(1) == 'edit') || (arg(0) == 'comment' && arg(1) == 'reply') || $title == 'test'){
    //  save the content being send with drupals function and dont pass it
    if (!empty($content)) {
        $comment_form = $content;;
    }
    //  with my call i dont send any content but pass the content from the previous call
    else {
        $output .= $comment_form;
    }
  }else{
    $output = '<h2 class="title">'. $title .'</h2><div>'. $content .'</div>'; 
  }
  return $output; 
}

it actualy works fine but the forms and their previews are formated in a silly way
in my layout there are two areas
one for the page-view nodes with black background
and below a white one for the comments
the black area has a fixed size and contains text, images or videos and the white area contains their comments
i think its not realy a exotic way to display content

the following problem also appears when im not placing the comments and their forms somewere:
-in the page view of a node - the node and its comments are at the right places
-when i reply a note - they are also at their right places
-when i preview a node reply - the note content is now below the comment area
(the node is getting appended to the form in comment.module, function comment_form_add_preview() line:1623 with (

  $form['#suffix'] = node_view(node_load($edit['nid']));) 

)
i can remove this with hook_form_alter()

-when i reply a comment - the node content is gone and at its place the parent comment is shown
-when i preview a comment reply - the node-content is gone and the parent comment is shown below the comment form
-when i preview a comment edit - the node-content is gone

i can get the nodes back in page.tpl.php with:

if(arg(0)=='comment'&&arg(1)=='edit'&&is_numeric(arg(2))){
  $nid = db_fetch_object(db_query('SELECT nid FROM {comments} WHERE cid = %d', arg(2)));
  print theme('node', node_load($nid->nid),false,true);
}
elseif(arg(0)=='comment'&&arg(1)=='reply'&&is_numeric(arg(2))&&is_numeric(arg(3))){
  print theme('node', node_load(arg(2)),false,true);
}
elseif($_POST['op']=='Preview comment'){
  print theme('node', node_load(arg(2)), false, true);
}
print $content;

but there are still some comment previews flying around in my theme
i realy dont get the point of gluing nodes and comments in this not flexible and nonuniform way together

of course i also tried around with the comment settings "Display on separate page" and "Display below post or comments"

if somebody nows if there is another way to customize comment-forms than changing the core comments.module
please tell me

jamov’s picture

I tried using these comment snippets (in this post above: http://drupal.org/node/122240#comment-252946 ) on my site, but with no results.
I followed the instructions above: I pasted those two snippets into my template.php and called the "theme('comment_wrapper')" inside my custom tpl.php file for the nodes which comments I'd like to theme/move around.
I checked out that $output is returned, but it's returned empty. If I add something to the $output it gets returned - so at least the right function is called from my node's tpl.php.

I must be missing something here? As obvious as that "something" might be, would you mind pointing it out? I've been stuck with this for quite a while now..

Thanks!

Emad11’s picture

I use drupal it is really great . Its features are mind blowing. It is very good for new comers. Your programs are really helpful. And this article is very knowledgeable. Your working style and new release are really mind blowing.

Football Kits

Anonymous’s picture

Solution is not the cleanest, but it works well and is easy to implement. I have Drupal put the comments at the bottom of the node, then use jquery to move the comment div :

<script>
$(document).ready(function() {
	$("#comments").insertBefore("#whatever-dom-element");
});
</script> 
elvis2’s picture

Hi,

I ended up paying someone for a solution to this problem. Here is the best way around this problem, to date. The solution has been tested on Drupal 5.1. Unfortunately it requires you to hack the core - just be sure to make a note to modify this again when you do an update to drupal core.

If you want to move the comment form to your liking, you need to call it (the comment form and comments) in the node-nodetype.tpl file... Here we go.

Open up node.module file and look for:

function node_show($node, $cid) {
    $node->cid = $cid;

    $output = node_view($node, FALSE, TRUE);

  if (function_exists('comment_render') && $node->comment) {
    $output .= comment_render($node, $cid);
  }

  // Update the history table, stating that this user viewed this node.
  node_tag_new($node->nid);

  return $output;
} 

And modify that too:

function node_show($node, $cid) {
    $node->cid = $cid;

    $output = node_view($node, FALSE, TRUE);

//  if (function_exists('comment_render') && $node->comment) {
//    $output .= comment_render($node, $cid);
//  }

  // Update the history table, stating that this user viewed this node.
  node_tag_new($node->nid);

  return $output;
} 

Then, you go to your node.tpl theme file and add this snippet where you want to call the comment form and comments:

if ($page == 1):
    if (function_exists('comment_render') && $node->comment):
        print comment_render($node, $node->cid);
    endif;
endif; 

If you have several node types, and you want to only move the comment form and comments on let's say, node type blog, you would do this instead.

function node_show($node, $cid) {
  $output = node_view($node, FALSE, TRUE);

// modified this to be able to call the comment form + comments where needed
if ($node->type != 'blog'): // we are going to call it seperately, in the node-blog.tpl file...
  if (function_exists('comment_render') && $node->comment) {
    $output .= comment_render($node, $cid);
  }
endif;

  // Update the history table, stating that this user viewed this node.
  node_tag_new($node->nid);

  return $output;
}

Then in the node-blog.tpl file, we add the same snippet as above:

if ($page == 1):
    if (function_exists('comment_render') && $node->comment):
        print comment_render($node, $node->cid);
    endif;
endif;

Please reference this post on other posts where you have read about this problem, so the drupal community will find this solution easier...

Happy comment form and comments moving!

Lionfish’s picture

Thanks for that!
I generally try never to touch core, but when it seems we've tried every possible alternative it looks like the only option.

Thanks for the help :)

elvis2’s picture

It is my pleasure. We should ask the drupal 6 team to consider a solution for the comment form and comments, so we won't have to hack the core the next drupal version.

michelle’s picture

Thanks to litwol on IRC for thinking of clearing out $node->comment.

Put this where you want it in your node-TYPE.tpl.php:

if (function_exists('comment_render') && $node->comment) {
   print comment_render($node, $node->cid);
   $node->comment = NULL;
}

Michelle

--------------------------------------
See my Drupal articles and tutorials or come check out life in the Coulee Region.

abu3abdalla’s picture

really i am soooooo happy now after doing my job
really thx for u and may god bless u

regards

mohd nashaat

tanc’s picture

I'm still seeing exactly the same problem in Drupal 6. The code that spits out the comment form is embedded in the node.module rather than being left to the theme designer. I don't want my comments within my node's node.tpl.php, I want them displayed elsewhere in my template's page.tpl.php. Is there no solution for this?

I've tried using litwol and Michelle's code above which will only work if the comments are set to display below the post and even then will display it twice as the node is still rendering the comments as well. If only they had made the very simple function node_show themable in node.module. That way we could choose to override the display of contents and add them in the template where we want.

I've submitted a feature request in the Drupal 6 queue, lets see if there are any takers... otherwise its hacking the node.module time.

dvessel’s picture

For Drupal 6, you can try this in template.php:

function phptemplate_preprocess_page(&$vars) {
  $vars['comments'] = $vars['comment_form'] = '';
  if (module_exists('comment') && isset($vars['node'])) {
    $vars['comments'] = comment_render($vars['node']);
    $vars['comment_form'] = drupal_get_form('comment_form', array('nid' => $vars['node']->nid));
  }
}

function phptemplate_preprocess_node(&$vars) {
  $vars['node']->comment = 0;
}

I loved the referenced variables. :) It makes this possible.

You must clear the theme registry for this to work.

Now you'll have $comments and $comment_form inside page.tpl.php which will output only when your focused on a node. Make sure you set the reply form to separate page first. It will break the form's js behaviors. It could be a simple fix.

Oh, and forget about the feature request for 6. It's too late. Would be nice to make it straight forward for 7.

joon park

tanc’s picture

Nice one dvessel, this is a good solution for Drupal 6.

alexis’s picture

It works like a charm and it's a good use of preprocess functions, thanks for the tip.

Alexis Bellido
Ventanazul: web development and Internet business consulting shouldn't be boring

daemon’s picture

If you need to use the node's comment mode in your theme, use :

node_comment_mode($node->nid)

instead of

$node->comment

daemon’s picture

This works perfectly but how do you fix the broken form javascripts? (they are no longer included on page load).

silverlite’s picture

It worked like a charm in 6.19!

To display the comments+comment form, I just added the line below anywhere in your page-mypage.tpl.php:

<?php print comment_render($node, $node->cid);?>

I used this feature to put a block just after the content of my page and just below it is the comments and the comment form.

Thank you very much dvessel for your solution!

geerlingguy’s picture

For Drupal 7, check out http://www.midwesternmac.com/blogs/jeff-geerling/moving-comments-block-d... - similar kind of implementation, but putting things into a custom block will allow you to simply drop the block in any region, and it will be rendered wherever you want on a page.

__________________
Personal site: www.jeffgeerling.com

nk126’s picture

This didn't work for me - the comments & submission form replicated instead of just moving. But the core hack worked like a charm. Thanks!

mokargas’s picture

Is there a way to remove the comment addition form from this?

jhedstrom’s picture

Note, this method, while elegant on php > 4, fails completely on php <= 4, due to the fact that objects are not passed by reference in php <= 4.

jamov’s picture

<?php
if (function_exists('comment_render') && $node->comment) {
   print comment_render($node, $node->cid);
   $node->comment = NULL;
}
?>

While this solution did what it's supposed to, it also made the Pager for the view (inside which the nodetype in question is displayed) dissapear!

Can you guys think of any workaround for that problem: dissapearing pager?

And I can say.. I spent hours on figuring out where did my pager go..

-jamov

smitty’s picture

Thank you, Michelle, for this great hint. It really works well and allows me to put all the comments into a block.

But I am afraid only the existing comments are rendered in the block. But the comment form is still remaining at the end of the node.

How can I achieve to get it into the block too?

Qrczak’s picture

I have the same problem. I don't know how to remove comment form and leave only comments.

Qrczak’s picture

I found (dirty) solution how to hide comments form when we add this code above.
In my case I can do this only via css.

.view-content-frontpage .node #comments .box {
display: none;
}

Unfortunately the form code is still in source of our page but it don't appear for visitor.

Few minutes ago I saw Panles 2 screencast (http://blip.tv/file/600413) and I think maybe this way we can also do that but I didn't try this yet.

smitty’s picture

Well I didn't try your solution yet, but I imagine that by hiding the comment form by css it'll be gone at all. How can I get it shown up in another place?
Panels2 might be a good solution to get the form into another column. But I am afraid it'll not work in my case because I want the form to show up in a block.

bokswagen’s picture

that was awesome. I was able to put this inside my jquery tabs. works perfectly. thanks

pguillard’s picture

It seems that this hack

<?php
if ($page == 1):
    if (function_exists('comment_render') && $node->comment):
        print comment_render($node, $node->cid);
    endif;
endif;
?>

as a limitation, when you send an empty comment or wrong captcha, page /comment/reply/200 apparears with the comment form outside the node again.

Phil

Steven_NC’s picture

subscribe

Zarabadoo’s picture

I seem to have a working solution in Drupal 6. This isn't totally tested yet, but so far it is working nicely and i have a lot of faith in it.

To do it, open up your template.php and adapt the following to yours:

<?php

function phptemplate_preprocess_page($vars) {
  if (isset($vars['node'])) {
    $vars['comments'] = comment_render($vars['node']);
  }
}

function phptemplate_preprocess_node($vars) {
  unset($vars['node']->comment);
}

?>

This should make a $comments variable available to the page.tpl.php. Using the _phptemplate_variables() function, you should be able to do much the same in D5. This is just the first step I am sure, and I plan to play with it more over the weekend.

--
Al "Zarabadoo" Steffen

--
Al "Zarabadoo" Steffen

whatever-’s picture

You're making the same thing that another user has done some comments above…

See: http://drupal.org/node/122240#comment-707961

jumpfightgo@groups.drupal.org’s picture

The comments are rendered where I put the $comment variable in page.tpl.php but they are also appearing as part of the $content variable.

Am I correct in assuming that the code below should take care of that? (It's not on my site, even after clearing the cache.)

function phptemplate_preprocess_node($vars) {
  unset($vars['node']->comment);
}

By unsetting the node variable, is the idea that the engine will not append comments to the node when creating the $content variable for page.tpl.php?

jumpfightgo@groups.drupal.org’s picture

My question specifically is if the code for D6 is supposed to replace the node.module hack described by pielgrzym or if you still need that hack. (I resorted to using the hack for now.)

netentropy’s picture

is there a similar function to separate all the $links in the out of box $links variable, like the read more etc

netentropy’s picture

why is all this done for page, why not node

after all it is the node.tpl that calls the link function where it is part of the array?

mean0dspt’s picture

Declare a region inside node.tpl.php like described here
http://drupal.org/node/361209

<?php print $content_bottom; ?> should go somewhere after $content

After that you have the whole region to put things in between of content and comments

hinchcliffe’s picture

how do I remove the existing comment now? I can move the comments to were ever I want but the existed comment is still under the node. How do I get rid of that?

Thanks, - Justin

newmediaist’s picture

Same question here - In Drupal 5, how do you move the comment form?

druryjeff’s picture

mcneelycorp's post from 9/19/07 (http://drupal.org/node/122240#comment-272809) is clearly described and works as advertised in Drupal 5.7

newmediaist’s picture

The problem is their solution requires you to modify the core, which I thought is a no no in the world of drupal?

elvis2’s picture

It is a no no. But in my case, no one had an answer and cared to create a solution. It seems now there is another option but others are reporting problems with the newest snippet. Back to square one...

===
Elvis McNeely
Drupal services: http://www.elvisblogs.org/drupal

momper’s picture

i totally agree at this point to hack the core (and i normally say no,no,no) in case of doubt - all this workarounds in such a substantial thing ... sometimes we "themers" can't spend days trying solutions, that are not 100% perfect at the end ... in 7 it's a must to have variables seperated from $content including seperate stuff for the form.

thanks a lot for all posted answers here ...
greetings momper

gausarts’s picture

I am on a no no side. Once I hacked the core, headaches strike:)

love, light n laughter
gausarts

love, light n laughter

andy tawse’s picture

got that all wrong. sorry!

grobemo’s picture

The Comment Display module does (in Drupal 6.x) what this thread tries to do. It prevents comments from displaying at the end of a node (i.e., at the end of $content) and creates a new variable called $comments, which you can place anywhere in page.tpl.php. (I'm not sure about node.tpl.php.)

robert-hartl’s picture

works not in the node-template. Just in the page template, what is quite disappointing.

hlopes’s picture

... to have these variables in node.tpl.php.

Been scrambling around this for ages!

If i can put a comment form through node.tpl.php, can't seem to preview the comment. If i do so, it takes me to comment/reply and throws a page not found error.

This is the code that i used:

print drupal_get_form('comment_form', array($nid), t('Post new comment'));

Any simple way to put this working?

Thanks in advance

hlopes’s picture

For Drupal 6

Just use this code in any .tpl.php.

$comments = comment_render($node);
$comment_form = drupal_get_form('comment_form',array('nid' => $node->nid));

print $comment_form;

Just make sure that you have $node set.

kpv’s picture

I was looking for a solution to use in node.tpl.php
This one works
Thanks a lot

axel pressbutton’s picture

Hi all,

Can anyone please tell me if the code posted earlier can be modified so that it only affects a specific node.tpl.php

My problem is that all comments have disappeared from other content types where I need the Comments to be displayed as normal :(

The code I'm using in my template.php is...

function phptemplate_preprocess_page(&$vars) {
  $vars['comments'] = $vars['comment_form'] = '';
  if (module_exists('comment') && isset($vars['node'])) {
    $vars['comments'] = comment_render($vars['node']);
    $vars['comment_form'] = drupal_get_form('comment_form', array('nid' => $vars['node']->nid));
  }
}

function phptemplate_preprocess_node(&$vars) {
  $vars['node']->comment = 0;
}

I've tried to add an 'if' statement in the second function but it doesn't appear to work correctly as it will render the comments normally in other content types and twice in the modified node.tpl.php

I know the code is probably way off but I tried...

function phptemplate_preprocess_node(&$vars) {
  if ($node->type == 'design_submissions'){
    $vars['node']->comment = 0;
  }
}

My node template is node-design_submissions and uses the following to render the comments and the form seperatley:

	$comments = comment_render($node);
	$comment_form = drupal_get_form('comment_form',array('nid' => $node->nid));

	print $comments;

and

	$comments = comment_render($node);
	$comment_form = drupal_get_form('comment_form',array('nid' => $node->nid));

	print $comment_form;

Any help would be greatly appreciated :)

axel pressbutton’s picture

Sorry about this but thought I'd post my findings just in case anyone else is looking.

To comments around on specific node.tpl.php files the function in template.php needs to be;

function phptemplate_preprocess_node(&$vars) {
	if ($vars['node']->type == 'content_type'){
	$vars['node']->comment = 0;
	}
}

...replacing content_type with your own content type value.

Cheers

slicedsoup’s picture

I've tried this and it does position the comments where I want them but every time I try to submit a comment It submits multiple times, almost like it is stuck in a loop of submitting.
Is anyone else having this problem? Any ideas why this would happen?

slicedsoup’s picture

Ok after a lot of trial and error I have found what seems to be a workable solution.
What I've been trying to do is get rid of the standard placement of the comments and manually position them inside my node.tpl.php
The problems kept arising that either I was getting no comments, no form, or 2 of everything.
Eventually following the suggestions above I got it the way I wanted but it resulted in multiple submissions for each posted comment (I'd be interested to hear if others have this problem)
Finally I went back to square one and tried to keep everything simple and here is the solution I found which seems to work now:
In the template.php add:

function phptemplate_preprocess_node($vars) {
$vars['comments'] = '';
if (function_exists('comment_render') && !empty($vars['node']) && $vars['node']->comment) {
$arg2 = arg(2);
$vars['commentshow'] .= comment_render($vars['node'], ($arg2 && is_numeric($arg2) ? $arg2 : NULL));
}
unset($vars['node']->comment);
}

and then in the node.tpl.php add when you what your comments rendered:

print $commentshow;

hope this helps

rixrix’s picture

Hi slicedsoup,

many thanks for the solution!

jdeg’s picture

I think the slicedsoup solution is the best :)

end user’s picture

The above works good but how would I go about listing the comments in a QuickTab using a block? If I insert this into the block

<?php 
print $commentshow;
?>

Then comments don't show as I think I need something to let the block know what page its on?

tommer’s picture

I found the solution how to insert comments into a block on this site: http://www.rubberneckdesigns.com/drupal-6-drupal-7/drupal-comments-in-a-...

Create the block and use php filter with this code:

<?php
  if (arg(0)=='node'&& is_numeric(arg(1))){
    $node=node_load(arg(1));
    
    print comment_render($node); 
  }
?>

Then you can select this block in Quick tabs.

Tested on D6.

bysv’s picture

Hi, i use the solution in http://drupal.org/node/122240#comment-707961 to move the form comment, but the form still shows the original site also.

I want to hide the original form and shown only that i want.

How i can hide the form??

Thanks

-----------

Solved!

Ivanhoe123’s picture

Can you post the solution please?

I'm having the same problem.

Thanks

PedroMiguel’s picture

butblack’s picture

Hi, I would like to do the same thing in Drupal 7. Any ideas? I would like to have a blog like entries down the left side and then on the right side the comments for all those entries. Any thoughts?

devtherock’s picture

I m fan of Panels module it gives you opportunity to add comments block anywhere even other things as well. But if you want to add through code here is link for it:

D6: http://api.drupal.org/api/drupal/modules--comment--comment.module/functi...
D7: http://api.drupal.org/api/drupal/modules--comment--comment.module/functi...

Thanks

regards
Dev/Kuldev

perumal.karthi’s picture

Thanks for the info, also does Panels provide ways to show Comments form?

scottatdrake’s picture

I'm surprised nobody has mentioned this yet. Worked well for me. http://drupal.org/project/commentsblock

rajmataj’s picture

Regarding the module commentsblock, this (7.x-2.0-beta1) is currently broken and does not work with Drupal 7.19 to show the comment form.

rjbrown99’s picture

I also needed to do this with Drupal 6, so I enhanced comment_bonus_api for this purpose.

In a nutshell, since the module already takes over node_show we have flexibility to do whatever we want with that function. I added an admin UI with a variable for each node type. You can now selectively enable/disable comment rendering on a per node type basis. This is generally in line with this idea: http://drupal.org/node/122240#comment-272809 but no core hacking is required.

Issue: #1555270: Selectively enable/disable comment rendering by node type

It's currently going to be in the -dev branch, so either use that or wait for 6.x-1.1 module release.

Note that if you use this approach you need to use comment_bonus_api_comment_render() to output your comments, not comment_render().

Here's what I dropped into my node-mynodetype-full.tpl.php:

<?php if ($node->comment): ?>
  <?php print comment_bonus_api_comment_render($node, $node->cid); ?>
<?php endif; ?>