Allowing themeing for nodes displayed in blocks

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Allowing themeing for nodes displayed in blocks

McBride, Ian S.
This one is a little more controversial, despite how small the change is. We have some complex content types that are displayed in both the center content region and in the sidebar using the Text for right column Monster Menus block. These content types have piles of fields that we want to display differently in each region. The simplest way to control the display is by theming the node, but we don't know where block or region the node is being displayed in at the time.

I found this a little frustrating about Drupal, to be honest, in that I think nodes should be able to tell what region they're in at the theme level. I tinkered with several solutions for this issue using the preprocess themeing functions, but wasn't able to come up with a workable solution. The easiest path that I saw was to let the node know what block (if any) was drawing it by including the block_id (delta) in its variables. The node-content_type.tpl.php and template.php theme files can them switch on $node['block_id'] to determine how to display the content.

I realize I'm probably getting obnoxious with patch volume at this point, so please feel free to leave this until you've got time to devote to it. I can just use this list as a convenient archive for the things I'll need to re-apply after I've updated from your trunk.

Also, thanks for the function reference for building the permissions update script. That will help tremendously.

---
You are currently subscribed to monster_menus as: [hidden email].
To unsubscribe click here: http://lists.middlebury.edu/u?id=685503.6b071f880fe6a965a128164e6d09ea81&n=T&l=monster_menus&o=446621
or send a blank email to [hidden email]

monster_menus.20090804.patch (4K) Download Attachment
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Allowing themeing for nodes displayed in blocks

Dan Wilga-2
At 2:41 PM -0400 8/4/09, McBride, Ian wrote:
>This one is a little more controversial, despite how small the
>change is. We have some complex content types that are displayed in
>both the center content region and in the sidebar using the Text for
>right column Monster Menus block. These content types have piles of
>fields that we want to display differently in each region. The
>simplest way to control the display is by theming the node, but we
>don't know where block or region the node is being displayed in at
>the time.

I think that, in general, the Drupal philosophy is to display a piece
of content the same way in all circumstances. Theme functions
generally control presentation, not the presence or absence of data.
So I would tend to agree that this is a low priority.

I do, however, have a suggestion which would work both with and
without MM. Use views to create two views, with the appropriate
fields shown in each. You can then theme them individually, or use
something like the View Reference module to display the view in the
context of a node.
--
Dan Wilga                                 [hidden email]
Web System Administrator/Programmer             http://www.amherst.edu
Amherst College                                      Tel: 413-542-2175
Amherst, MA  01002

---
You are currently subscribed to monster_menus as: [hidden email].
To unsubscribe click here: http://lists.middlebury.edu/u?id=685503.6b071f880fe6a965a128164e6d09ea81&n=T&l=monster_menus&o=446646
or send a blank email to [hidden email]
Loading...