Theming a node several ways

We encourage users to post events happening in the community to the community events group on https://www.drupal.org.
gadehans's picture

Theming a node in the node.tpl.php only gives you to options, full page view or teaser! What do you do, if you want to theme the same node in several different ways depending on what region the node is shown in?

The thing I'm trying to do is, to have a node (an article) be a top story in the "Top story" region one day, and another story in another region the other. That is, I want to be able to theme a node differently depending on region.

I would like to do it in node.tpl.php, but as I see it, there are no variables available in a node that can tell you what region the node is in.

I have been thinking about using the function "template_preprocess_node" of drupal 6, to make the relevant variables available to the node, and since I'm using nodequeue/views to put the node in regions, there is an option to make a call to the database in "template_preprocess_node" and thereby detecting which nodequeue a specific node belongs to. Making this information available in node.tpl.php would be a way of "theming by nodequeue", but not actually "by region".

fundamentally, this is a problem of making a node "know" where it is on a page, i.e in what region.

Does anybody have e reasonable solution to this - preferably a solution that uses the node template. (Panels solutions are welcome, but since I'm working on a production site, and Panels for Drupal 6 is still in beta, I,m not very happy to go down that path)

Comments

Use view template

gadehans's picture

If it is of interest to anybody, I solved this problem myself, without using Panels.

As I stated, I'm using nodequeue to put different nodes in. I'm placeing these nodequeues in regions and want these nodes styled differently denpending on which region they are in.

The solution is to use a view template - when you create a nodequeue, a view is automatically generated. Nodes appearing in this view can now be style in a template file by the name node-view-VIEWNAME.tpl.php.

I hope this can be of help to somebody besides myself.

just bookmarking

SunflowerMission's picture

great post. thanks

Newspapers on Drupal

Group organizers

Group categories

Topics - Newspaper on Drupal

Group notifications

This group offers an RSS feed. Or subscribe to these personalized, sitewide feeds: