Been sitting on this idea for a while: curious to see what people think.
In a nutshell, the idea is to combine and generalize the various flags for a node that are available in node.tpl.php, and open them up to modules.
For example, instead of the $is_front, $page, $sticky, and $teaser booleans, you'd have an array with entries present if the flag is true. Something like this, for example:
$context = array(
'teaser' => array(),
'sticky' => array(),
'page' => array(),
);Core would take care of shoving those keys in; other modules would given a chance to add their own to a node.
That's the plan. Here's why I think it's cool:
-
Blogs
Has anyone else noticed that it's a bit weird to have the user picture repeated over and over again on the /blog/xx page, when we already know it's Joe Bloggs' blog? Wouldn't it be more logical to have it show a) on every post on the /blog page, which is a mixture of people, b) on the individual blog nodes, and c) if we're being really cool, just the once at the top of a personal blog roll?
The $page/$teaser distinction doesn't give us this level of subtlety.
With a context list, the blog module could shove in its own flag to the $context array, such as 'blog_user' or something, and then skip the $picture in that case.
To get the picture on the first one in the list, you could shove in a 'first'... and that would have a LOAD of cool applications with theming. -
Views
There's a huge number of things this would be good for views.
I often find I do a load of view theming, when all I really want to do is say 'don't show the node links on teaser nodes in this view' (and I want a teaser list; really don't want to reinvent the wheel styling a list view).
If the views module dropped both a 'views_view' and a 'views_{viewname}' item into $context, a simple switch in the node template would do the job. -
Headings
A simple input format to handle headings is something I'd really like to see. Something wiki-like, with "== heading ==" turning into an H2 would be great for a lot of purposes.
However, you're almost sure to get badly-nested HTML, because while in the standalone case ($page), H2 is probably the next heading level down from the node title, it's probably not in a teaser list. And when you get the views, the plot thickens.
I've not entirely considered the ramifications of this, as it would have to be done at the theme level, because different themes use different hierarchies of headings... but you'd definitely need some indication of node context.
Comments and ideas?
Ought this to be done to the flags in the $node object too? There's currently a redundancy between $node->sticky and the $sticky available to node.tpl.php, for example. Is that something that can do with tidying up while we're at it?
