Hacking Blogger templates
The ultimate goal here was filtering of posts based on inclusion (or even better, exclusion) of posts with certain labels. (Read this post first for context.)
[Update: before you think about imitating the following approach, you should know that I gave up with Blogger and switched to WordPress which is far more flexible and easy to hack.]
Unfortunately it turns out that Blogger’s XML-based template layout system is not quite as flexible as it first seems. It’s almost superb, but has some key omissions:
- Flow control is limited to
<b:if>,<b:else>, and<b:loop>. Crucially, you can’t break out of a loop. - No writable variables of any kind.
- Conditional testing via
<b:cond>is extremely limited. I kept expecting to find some comprehensive documentation for thexmlns:exprnamespace (which is used via things like<a expr:href='data:blog.homepageUrl + "search/label/foo"'>), but it doesn’t exist, simply because all you can really do is simple comparisons using a limited set of data and hardcoded strings. - There are no string-handling functions, and you can’t get access to the current
QUERY_STRINGto do any kind of parametrisation (for example, show some HTML saying which label you are currently viewing based on what comes after/search/label/in the current URL). - The box generated by the status-message includable is hardcoded to either be invisible or say “Showing label foo. Show all posts”. It cannot be customised.