2

I'm trying to display the comments on a node at the top of the page. I've edited node.tpl.php in my theme to be:

<article id="article-<?php print $node->nid; ?>" class="<?php print $classes; ?> clearfix"<?php print $attributes; ?>>

  <?php print $unpublished; ?>
  <?php print render($content['comments']); ?>
  <?php print render($title_prefix); ?>
  <?php if(!empty($user_picture) || $title || (!empty($submitted) && $display_submitted)): ?>
    <header class="clearfix<?php $user_picture ? print ' with-picture' : ''; ?>">

      <?php print $user_picture; ?>

      <?php if ($title): ?>
        <h1<?php print $title_attributes; ?>>
          <?php if ($page): ?>
            <?php print $title; ?>
          <?php elseif (!$page): ?>
            <a href="<?php print $node_url; ?>" rel="bookmark"><?php print $title; ?></a>
          <?php endif; ?>
        </h1>
      <?php endif; ?>

      <?php if ($display_submitted): ?>
        <div class="submitted">
        <?php 
            //By:   Mike Ghen 
            //Date: 5/21/2012
            //Description: This Modifies the submitted user and date info.
            //             Code from: http://drupal.org/node/1072640
            if ($submitted) { 
                echo "Submitted on " . date( "F j, Y",$node->created);  
            } 
        ?>      
        </div>
      <?php endif; ?>

    </header>
  <?php endif; ?>
  <?php print render($title_suffix); ?>

  <div<?php print $content_attributes; ?>>
  <?php
    hide($content['comments']);
    hide($content['links']);
    print render($content);
  ?>
  </div>

  <?php if ($links = render($content['links'])): ?>
  <?php endif; ?>



</article>

I moved <?php print render($content['comments']); ?> to the top of the page but, it makes the form to fill out a comment appear at the top of the page as well. Is there a way to render the comments at the top and the comment form at the bottom?

1

you attack this line in file :

<?php
    // Remove the "Add new comment" link on the teaser page or if the comment
    // form is being displayed on the same page.
    if ($teaser || !empty($content['comments']['comment_form'])) {
      unset($content['links']['comment']['#links']['comment-add']);
      unset($content['links']['comment']['#links']['comment-comments']);
            unset($content['links']['comment']['#links']['comment_forbidden']);
    }
    // Only display the wrapper div if there are links.
    $links = render($content['links']);
    if ($links):
  ?>
    <div class="link-wrapper">
      <?php 
      hide($content['links']['comment']['#links']['comment-comments']);
      print $links; 
      ?>       
    </div>
  <?php endif; ?>
0

You are editing a node template , in this situation you are not able to change an element itself , but you can go to comments module , there you can find a template file inside which generates the comment output , copy it to your theme folder/templates then modify it there and changes will be applied. An easier solution could gain by using Panels and page manager . it will take you just some mouse clicks.

protected by Community Jul 13 '15 at 3:31

Thank you for your interest in this question. Because it has attracted low-quality or spam answers that had to be removed, posting an answer now requires 10 reputation on this site (the association bonus does not count).

Would you like to answer one of these unanswered questions instead?

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