New Podcast

Posted Tuesday, July 27 at 2:29 pm

Ryan Price and Mike Anello recently talked with Jacob Redding (jredding), author of Beginning Drupal as well Treasurer and Interim General Manager of the Drupal Association.

Download Podcast 41
DrupalEasy_ep41_20100727.mp3
Syndicate content

NEWSLETTER

Stay informed on our latest news!

Syndicate content

Testimonial

DrupalEasy is by far on of the best ways to learn Drupal; Mike & Ryan completely immerse you into the complex world that is Drupal. Their easy to understand teaching technique and approach to explaining site administration, in a way any newbie or long time Drupaler can understand, makes the DrupalEasy workshops an important and invaluable experience for anyone who wants to become a Drupalista.

Who are we?

DrupalEasy is the collective expertise of Ryan Price and Michael Anello, who joined forces to provide training and consulting services worldwide. Read all about them and what they can do.

What is Drupal?

Drupal is a free, super-powerful content management system for sites that require information posting and collection, including blogs, forums, videos, photos, and databases of information. We think it is the best platform available. Here's why...

Why Drupal?

More and more savvy organizations are going with Drupal for content management, and its no mystery why. It’s free, flexible, and easy to maintain for small or large volume sites. Learn more...

Moving the comment form without hacking core

No votes yet

One of the most frustrating things about Drupal's current architecture is that comments, and the form to post them, are attached to nodes and don't easily allow you to move them around in your TPL files. There really should be an easier way to just place them anywhere you'd like. Most times this doesn't get in your way, until you want to do some fancy layouts where your content is split into multiple columns on the page. After going round and round with this, I finally happened upon a discussion on Drupal.org that solves this for 5.x rather easily with a snippet of PHP:

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

Just place this code anywhere in your TPL files where you'd like to move the comments and be happy that you didn't hack core.

Happy Drupaling!

Trackback URL for this post:

http://drupaleasy.com/trackback/14

10 comments

Guest wrote 1 year 22 weeks ago

Are there any modules that

Are there any modules that allow you to make changes to the comment form (number of rows in text area, hiding elements, etc?)
Guest wrote 1 year 27 weeks ago

This is a great hack, but as

This is a great hack, but as soon as i make a mistake on the comment form (empty or wrong captcha), the page is displayed again with the hack not working, the form is outside the node again... if (function_exists('comment_render') && $node->comment) returns true... Do you have an idea ?
David Peterson wrote 1 year 29 weeks ago

You are brilliant!! I have

You are brilliant!! I have been searching for something like this for a long time and couldn't get it going.

Thank you.

user picture
ryanprice wrote 1 year 33 weeks ago

ajay, You'd still use this

ajay,

You'd still use this snippet.

As the original thread states, you'd put this where you want it in your node-TYPE.tpl.php, and the regions should be available on node templates just as easily as page templates.

Correct me if I'm wrong.

For Drupal 6, check out Joon's comment a few lines down:
http://drupal.org/node/122240#comment-707961

ajayg wrote 1 year 33 weeks ago

It works if you want to

It works if you want to treat comments list and the new comments form as one block. But if you want to insert a region say in between list of comments and new comments form, how would you do that?

user picture
Lopsta Ecommerce wrote 1 year 34 weeks ago

themeing stuff is such a

themeing stuff is such a nightmare on drupal. everything else i just love, but getting the html output that you plan to get is a real pita. but i have to say i'm still on D5, ppl told me D6 is much better.
Anyway, thanks for sharing the code.

ericmarden wrote 1 year 43 weeks ago

You can, but I tend to use

You can, but I tend to use mini-panels more, and just place them in custom block regions, instead of using full blown panel pages. Plus, for the end node pages, sometimes you just want to move it for one type of content, and not all the others.

- Eric Marden

- Eric Marden

user picture
ryanprice wrote 1 year 43 weeks ago

@venkat-rk While I agree

@venkat-rk

While I agree that you could probably create a single panel that drives EVERY page on your site, sometimes you just need to hand a brother a .tpl.php file, you know?

Davy Van Den Bremt wrote 1 year 43 weeks ago

Great tip! If only I had

5

Great tip! If only I had known this earlier. Needed this on http://www.donna.be and a few other sites.

Thanks!

venkat-rk wrote 1 year 43 weeks ago

Couldn't this be done with

3

Couldn't this be done with panels?

Syndicate content