Search code examples
phpdrupaldrupal-7drupal-theming

how to change comment header in particular node type in sub theme in drupal 7 using comment-wrapper-<content-type>.tpl.php


Hi I am new to Drupal Development. I am trying to alter comment section of article content. My requirement is I want to change the header in [Comment Section] 1 from Add New Comments to to add new review and comments to previous reviews ,and subject to review subject in my subtheme which uses bartik as base theme.

Can anyone help me. Here is the code which I altered in comment-wrapper-article.tpl.php in sub theme.But I can't alter the display.

<?php
<div id="comments" class="<?php print $classes; ?>"<?php print $attributes; ?>>
<?php if ($node->type == 'article'): && $node->type == 'article');?>
<?php print render($title_prefix); ?>
<h2 class="title"><?php print t('previous Reviews'); ?></h2>
<?php print render($title_suffix); ?>
<?php endif; ?>
<?php print render($content['comments']  ?>
<?php if ($content['comment_form']): ?>
<h2 class="title comment-form"><?php print t('Add New Review'); ?></h2>
<?php print render($content['comment_form']); ?>
<?php endif; ?>
?>

Solution

  • Finally I had Succeed in getting the solution to the problem, in case if any one faces the same problem.Here is the solution.

    <div id="comments" class="<?php print $classes; ?>"<?php print $attributes; ?>>
    <?php if ($content['comments'] && $node->type != 'forum'): ?>
    <?php print render($title_prefix); ?>
    <h2 class="title"><?php print t('Previous Reviews'); ?></h2>
    <?php print render($title_suffix); ?>
    <?php endif; ?>
    <?php print render($content['comments']); ?>
    <?php if ($content['comment_form']): ?>
    <h2 class="title comment-form"><?php print t('Add New Review'); ?></h2>
    <?php print render($content['comment_form']); ?>
    <?php endif; ?>
    </div>
    

    the main requirement is the file name should be in the following format."comment-wrapper--node-contenttype.tpl.php"