[development] proposal for theming nodes

Darrel O'Pry dopry at thing.net
Wed Dec 14 21:30:15 UTC 2005


On Wed, 2005-12-14 at 16:00 -0500, Syscrusher wrote:
> On Wednesday 14 December 2005 12:38, Darrel O'Pry wrote:
> > I'm in full agreement. posted the same thing on the theme list.
> > I think node->extra is probably a better name than the node->html i
> > suggested, but still a little too abstract. Maybe node->rendered since
> > we are talking about themed output whether its html, xhtml, rss, atom,
> > or whatever.
> 
> What about three arrays:
> 
>    $node->before[] and $node->after[], to tell the themer that the
>    added content is logically before or after the node body
> 
>    $node->extra[], to add content that has no specific sequential relation
>    to the node
> 
> Note that this is *not* intended to imply any particular placement on the
> page, but rather a relationship to the node having to do with the order
> in which the user should see the content. How the theme places it could
> be left-to-right (or the reverse, for some languages), top-to-bottom, on
> a diagonal, or ... whatever. In many themes, this may imply order of HTML
> emitted, but in other themes, it may relate to prominence (size and/or
> decoration) rather than strictly sequence.
> 
> The behavior would be that each module can optionally add pre-themed
> content to $node->before[$module_name] (and so on), and the page theme
> would then insert the concatenation of these arrays in a place of its
> choosing.
> 
> The before, after, and extra semantic is advisory to theme developers, not
> binding upon them. Default themes could take the simple course and simply
> prepend and append before[] and after[], respectively, and put extra[] in
> some reasonable place (maybe between the node body and after[]).
> 
> Scott

I've been testing a local branch using the snippet below..

ordering is important, and should be a ui option, but a simple before
and after won't really suffice. I don't think the cms should have any
set notions of where things belong. I think a more generic weighting
would be more appropriate, maybe prepended to the key of
$node->rendered... so a simple ksort of node->rendered or $value can
handle the ordering...


0_nodevote, 1_node, 3_book it gets pretty easy to make them sortable...
but making the key naming consistent and programmatic is what I need to
figure out.   


in theme.inc: theme_node 
foreach($node->rendered as $key => $value) {
 $output .= is_array($value) ? join("\n", $value) : $value;
}

phptemplate.engine: phptemplate_node
foreach($node->rendered as $key => $value) {
 $variable['content'] .= is_array($value) ? join("\n", $value) : $value;
}









More information about the development mailing list