I came across a Sitemap generation code), the idea interested me enough to do a bit more research into the topic, and try to work out the details.
So here's some notes on the hows and whys of using code to change layout details. (I'm working on Sitecore 6.6 here, but this information is relevant to many versions of Sitecore)