I want to show comments of a node on a separate page instead of on the node page. Since this is just a "comment archive" and not active I would like a simple solution without a big module or a lot of code.

I can "hack" the node--mytype.tpl.php page to show comments when the "?archive" is in the URI:

    $uri =  check_plain($_SERVER['REQUEST_URI']);
    if (strpos($uri, '?archive') > 0){
        print render($content['comments']); 
    else {
        print l('View Comment Archive', $uri.'?archive');

This works fine, even with the comment pager. I'm curious what the "proper" way in Drupal would look like.


I would use the Views module for this. Even though you don't want to use a "big module" but Views is used in almost every Drupal site and will allow you to do this without custom code.

Here are the quick steps:

1) Create a new view of Comments with a display type of "page" and a url of "node/%/archived" enter image description here

2) Add a contextual filter that uses "content id from url" as a default argument enter image description here 3) Add a "Menu tab" by clicking menu and title it "Archived".

Viola! There will be an archived tab on your nodes with all comments.

enter image description here

|improve this answer|||||

The easiest way to to use Views.

You can create a view over Comments, or you can make a view over Content and then add a relationship to the node's comments. There are advantages and disadvantages to both. You just need to play with them to see what works best for your situation.

With either method, you can use any of the normal means for adding a view to you site.

|improve this answer|||||

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.