[development] proposal for theming nodes

Nedjo Rogers nedjo at islandnet.com
Wed Dec 14 17:03:04 UTC 2005


>  it would be nice for me to comprehend these theme changes you guys are 
> discussing.

Trae, here's a quick explanation.

When data on a 'node' is passed to a theme, it comes as an object, called 
$node, that has various 'properties'.  So, for example, there's 
$node->links, which is a set of links, $node->body, which is the main text, 
and so on.  A themer can do anything she/he wants with these.  It's the 
separating out into separate 'properties' of the $node object that allows us 
to say "the body should look like this and be presented here".

But how to we add extra things that the theme doesn't already know about? 
Say we want to add an image to a node.  This is the sort of thing you can do 
easily in a module.  You can say, "you know this $node object, well, I want 
to add another property to it, let's call it $node->image, and let's make it 
a tag like <img src="somepath.png" />".

The problem is that the theme won't know anything about this 'image' 
property of the node.  It just knows about the standard set of properties 
(body, links, and so on).  True, we can edit a particular theme so that it 
looks for $node->image and does something with it.  But then the code will 
only work with that particular theme.  Everyone else won't see anything.

So how module authors handle this now is to say, "Well, I guess I can't add 
my content as a new property of $node, so I'll just add it to one of the 
existing properties.  $node->body makes the most sense.  So you know this 
image we want to add?  We'll just add it to whatever's already in the node 
body.  So now $node->body equals whatever it had before plus my image."

Then, when this hits the theme, the theme outputs the body, and along with 
it whatever was added along the way.

What Ber is saying is, that kinda sucks.  We should have some way of adding 
content without just lumping it together with whatever we already have in 
the body.  Let's find a way of separating it out, and let's make themes 
smarter, so they can discover new properties that have been added.  That 
way, we'll end up with a lot more control over display.

Once this sort of thing was done, you as a themer could say--Any images 
added?  Okay, let's do this with them. 



More information about the development mailing list