By feelexit on
We can theme page, block and node based on content type
ex.
* node-story.tpl.php would theme only story nodes.
* node-page.tpl.php would theme only page nodes. (Note that this is different from page.tpl.php which controls the layout of the entire page including header, sidebars, etc)
* node-forum.tpl.php would theme only forum nodes.
* node-book.tpl.php would theme only book nodes.
I try to do the same on comment, its not working.
comment-forum.tpl.php, I want to make my comment looks differnt for forum post and story. Can we do it ?
Comments
Note by default
Note by default but there are some approaches that would allow you to theme based on content type.
In both cases it relies on the fact the one of the variables available is $comment which has nid field so you can get the node by
One way to use this is in comment.tpl.php, you could modify it to get the node and add a class to the outer div that reflects the content type the comment applies to. At that point you could use CSS to style the comments differently.
It is also possible to provide template suggestions (so comment-forum.tpl.php would work). Since this is build into Drupal 6 I am going to assume you are using Drupal 5. For Drupal 5 I think this will work (untested)
This would either be added to your themes template.php file or if it already has _phptemplate_variables() deleclared the two functions would need to be merged.
thank you so much.
thank you so much.
If you want to go the
If you want to go the comment.tpl.php route, here's what my comment.tpl.php file looks like (I've got a separate look for blog comments):
You can modify the if statement to include more node types, or expand it to add additional looks based on node type.
(thanks for the suggestions above... I was struggling with theming comments for a while, and finally got it working today. Wasn't successful going the template.php route)
Brad
Put this in the manual !
Who can add this to http://drupal.org/node/11815
???
Thanks a lot !
documented for D6
here: http://drupal.org/node/1089642
Nicolas
-------------------------