dongtan6336
dongtan6336
2017-02-08 09:04

如何使用comment-wrapper- <content-type> .tpl.php更改drupal 7中子主题中特定节点类型的注释头

已采纳

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; ?>
?>
  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 复制链接分享
  • 邀请回答

1条回答

  • duankuixi1930 duankuixi1930 4年前

    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"

    点赞 评论 复制链接分享