The sub-theme for the Answers module, answers_theme, messes up what comments look like and how they are configured in the main theme across the site. There is no comments--mysubtheme.tpl.php file. What else could be causing this issue?

I am building a custom sub-theme based on answers_theme which should only affect the part of the website it's designed for but it's affecting comments site-wide. To build the sub-theme, I've copied the files in answers_theme and changed the name of the module, updated all the hook references in the .module file, updated the .info file, etc. Everything works as I want it to except I can't figure out what part of the original sub-theme code is causing the comments of the main theme to mess up.

I tried copying the comment.tpl.php out of the main theme and renaming it to comment--mysubtheme.tpl.php within the subtheme template directory but that didn't help.


The templates are in the module, located here:


If you copy those templates into your active theme, they become the override and you can do as you please from there.

I am not familiar with the Answers module, but if you don't want comments to show on them, you could probably edit the node--answers.tpl.php and remove the line that renders comments.

This line: <?php print render($content['comments']); ?>

That might do it.

But generally, copying templates from modules into your theme sets that as the template override if you're looking to add, remove, or modify what is being output. It is kind of rare (IMO) to have to unset theme hooks as a means of controlling or suppressing output at a template level.


Since we're not going to use comments for this feature, I removed the following code from my custom version of the answers_theme.module and the problem went away.

 * Implements hook_preprocess_comment().
 function discuss_theme_preprocess_comment(&$vars) {
  $bundle = isset($vars['elements']['#bundle']) && $vars['elements']['#bundle'];
  if ($bundle == 'comment_node_answers_answer' || $bundle == 'comment_node_answers_question') {
    $vars['theme_hook_suggestions'][] = 'comment__node_answers_theme';
  • 1
    Not a good idea to edit code you do not control - the next time you update this module it will wipe out that change. I can't find that code in the module, where is it located? – Kevin Aug 18 '17 at 2:08
  • Hi, sorry I wasn't clear. I created a custom module and theme and I based it on (took the code from) a different module called answers_theme. It's part of the answers module package that can in installed separately. The code is in answers_theme.module so I had brought it over to mycustomeanswers_theme.module. I hope that makes more sense. – Christia Aug 18 '17 at 2:26

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.