New renderCss macro
Inspired by recent works from Carlos Grenier and Andy Fragen, as well as the new, 'released at last', and amazing (thanks Dave) Radio instant ouliner, I've created a macro to render opml outlines with css support directly in a weblog page.
In s l a m's home page, the headlines at the top, the links on the left, and the previous two posts are defined in opml outlines. Check headlines.opml, navsection.opml, resources.opml, and instant outliner.
These files were created using Radio's outline features. s l a m's #homeTemplate includes three instances of the renderCss macro:
For headlines, <% renderCss ( "Data:Marc:Radio UserLand:www:gems:opml:headlines.opml", "headline", 2, 1 ) %>.
For navsection, <% renderCss ( "Data:Marc:Radio UserLand:www:gems:opml:navsection.opml", "navsection", 2, 0 ) %>.
For resources, <% renderCss ( "Data:Marc:Radio UserLand:www:gems:opml:resources.opml", "navsection", 2, 0 ) %>.
The homeTemplate's header also includes a tag that loads a related css stylesheet:
<link rel="stylesheet" type="text/css" href="gems/css/homeTemplate.css">.
renderCss' mandatory first argument is the full path name to the opml file to render. On a Windows system, use '\\' instead of ':' as a folder separator.
The second optional argument is the name of a css class. If none is supplied, renderCss uses 'l' by default. Every headline level in the outline is numbered by renderCss from 1 to N, N being the depth of the outline (for instance, N = 2 for the headlines and navsection outlines on this page).
Every headline in the outline is rendered inside a paragraph, with a class attribute formed by concatenating the second argument with the current level (by default, <p class='l1'> for first level headlines, <p class='l2'> for the second level and so on).
The third optional argument is the maximum depth rendered in the outline. It defaults to 0, no limit. If an outline has a depth of 4 levels, but renderCss' third argument is 2, all subs of level 3 and 4 are ignored when rendering.
The fourth optional argument is the maximum length rendered in an outline. It defaults to 0, no limit as well. If an outline includes 4 headlines of level 1, but renderCss' fourth argument is 2, only the first 2 root headlines and their subs are rendered, the remaining 2 are ignored. The way headlines.opml is rendered on this page is a good example for an argument value of 1.
If you don't have a headache by the time you finish reading this post, you should be worrying.
The source code for renderCss is available here. Save it as a renderCss.txt text file in Radio's Macros folder, then start including opml oulines everywhere.
1:57:50 AM Google It!