0

I've got my comments for my nodes looking good ON the node. However, as an admin, or using the permalink, if you go to the actual comment page (/comment/comment#) it looks funky. I'd like to format it so the sharebar doesn't appear, the whole node doesn't appear, all the rest of the comments don't appear, and the ability to add yet another comment doesn't appear. I JUST want the comment to appear on that page. Sort of like when you go to comments > edit (as an admin).

Does anyone know how to edit this page or what the template file is at least so I can edit that?

Thanks!

2 Answers 2

1

You can achieve the same by adding template_preprocess_node in template.php of your theme as shown below:

function <THEME_NAME>_preprocess_node(&$vars) {
    $path = explode('/', request_path());
    if ($path[0] == 'comment' && is_numeric($path[1])) {
        $node = $vars['node'];
        unset($vars['content']);
        $comment = comment_load($path[1]);
        $vars['content'] = comment_view($comment, $node);
        unset($vars['content']['links']);

        //If you want to set separate tpl for comments section
        $vars['theme_hook_suggestion'] = 'node__comment'; //Need to create node--comment.tpl.php
    }
}

Update #1

To add page--comment.tpl.php add following function to template.php file:

function <THEME_NAME>_preprocess_page(&$vars) {
    $path = explode('/', request_path());
    if ($path[0] == 'comment' && is_numeric($path[1])) {            
        //If you want to set separate tpl for comments section
        $vars['theme_hook_suggestion'] = 'page__comment'; //Need to create page--comment.tpl.php
    }
}

Remember to clear cache after adding this function to template.php

2
  • is it also possible to do $vars['theme_hook_suggestion'] = 'page__comment';? Or how would one do that...I tried that and it didn't use the page--comment.tpl.php I created. The reason i want this is because the sharebar module is outside the context of the node, and I need to hide it on this page.
    – Sage
    Commented Mar 10, 2015 at 17:40
  • please check update #1 for page--comment.tpl.php in answer. Commented Mar 10, 2015 at 17:52
1

As the comment page does not use it's own theme so you probably have to do it as outlined in this question.

But, If you just want to redirect the comment page back to the original post, the latest dev version of the Global Redirect module has a setting for this. I recently did this on a site as the comment pages were causing SEO problems.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.