开发者

How can I control the placement of the comments region in Drupal 6?

I'm developing a theme for a Drupal blog; the mock-up I created requires the post content, trackbacks block and comments block to appear in a central column, with borders running either side.

I've got the CSS and HTML working correctly, so that's not the issue here. My problem is that the comments block as generated by Drupal is placed outside of the div defining the central column, and so it appears out-of-place. As such, I think the solution is to stick a line into my theme saying "print column block here", but having scoured the Drupal docs I can't see any way to do so. Based on the HTML output by Drupal, I'm not sure a CSS/HTML fix is going to work.

I'm sure other Drupal theme developers must have come up against this before.开发者_运维百科..


In the node.tpl.php you can create the html for the node's full display (the node is being viewed). You can create templates for each node type, fx node-blog.tpl.php etc. The default node template just prints $content, but if you want, to can instead print the each item separately with the desired markup.

This is less dynamic, as you would need to add new items if they were added to the node, but it does give you more fine grained control over the markup. This is the most simple solution I can think of.

To place the comments use this snippet:

<?php print comment_render($node); ?>

or lookup the comment_render() function


There are several ways to address this in Drupal 6.

Using something like the comment_display module, you can manually place the comments anywhere in your page.tpl.php file.

Alternatively, you can do something similar using panels.


I eventually managed to resolve this using an HTML and CSS fix after all. It's not as seamless as I'd like, but it's not the end of the world.

Thanks for the suggestions, I hadn't anticipated that things like comments would be output as part of the node content!

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜