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
- CommentsIs very different than
- View
- Blog
- Comments
- Blog
- Comments
- Blog
- CommentsI 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?
| Comment | File | Size | Author |
|---|---|---|---|
| #2 | 1157890-redo-node-rendering.patch | 5.04 KB | dawehner |
Comments
Comment #1
dawehnerSo 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
Comment #2
dawehnerWow 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
Comment #3
dawehnerTested a bit more and commited.
Comment #4
RobW commentedAwesome. Testing now, thanks for the quick response and great patch, Dereine.
[edit] Works perfectly.
Comment #6
dawehnerHere is a follow up for that: #1871082: Theme suggestions for node aren't shown wow!