I created a very simple blog feed in Views 3 -- an unformatted list that displays full node content of type article. In my node--article.tpl.php, I have custom markup that prints the comments at the end of the node. Heavily simplified, it's something like this:

<div class="blog-node">
<!-- ...bunch of node code... -->

<div class="special-comment-wrap">
<?php print render($content['comments']); ?>
</div>

</div>

If I don't select "Display Comments" in the Show:Content settings, no comments are shown, as expected:

<div class="blog-node">
<!-- ...bunch of node code... -->

<div class="special-comment-wrap">
<!-- Nothing here. Looking good. -->
</div>

</div>

But when I choose "Display Comments", views doesn't respect my node--article.tpl.php. It inserts the rendered comment array after the node, like this:

<div class="blog-node">
<!-- ...bunch of node code... -->

<div class="special-comment-wrap">
</div>

</div>

<!--what would be the results of <?php print render($content['comments']); ?> -->

Un-nesting my comments causes problems with my document outline, and display inconsistencies when compared to the normal full node view as rendered by node--article.tpl.php. In the html5 I'm working on

- View
  - Blog
    - Comments
  - Blog
    - Comments
  - Blog
    - Comments

Is very different than

- View
  - Blog
  - Comments
  - Blog
  - Comments
  - Blog
  - Comments

I can understand situations where it would be beneficial for views to act this way, but it's a problem for me. Any ideas on how to get views to respect my tpl?

CommentFileSizeAuthor
#2 1157890-redo-node-rendering.patch5.04 KBdawehner

Comments

dawehner’s picture

So just a summary what's the problem

* Views tend to have a views-view-row-node-view.tpl.php because there was no other way in d6 to rend the comments as well
* In D7 the comments got moved into the node.tpl.php
* So the plan
* Get rid of row-node-view.tpl.php
* Move the preprocess code into hook_node_view for the comments part
* Move the preprocess code into hook_preprocess_node for the links part

dawehner’s picture

Component: comment data » node data
Status: Active » Needs review
StatusFileSize
new5.04 KB

Wow this wasn't that easy thought.

Here is a patch which works fine for me:

* use right view_mode
* display links if wanted or not
* display comments if wanted or not

dawehner’s picture

Status: Needs review » Fixed

Tested a bit more and commited.

RobW’s picture

Awesome. Testing now, thanks for the quick response and great patch, Dereine.

[edit] Works perfectly.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

dawehner’s picture

Here is a follow up for that: #1871082: Theme suggestions for node aren't shown wow!