Tech
Tech Peter LamutHow to change element's ID with Diazo?
A common scenario: on your website all subpages share a common header, but you want a different header on the front page. Let's say you differentiate between both header versions by their ID attribute and define two different sets of CSS rules for each version. When applying Diazo rules to a theme file, you therefore need to change header element's ID, depending on whether the first page or one of the subpages was requested. Here's a snippet from rules.xml, which does exactly that:
<!-- change header's ID attribute -->
<prepend css:theme="#header-index">
<xsl:attribute name="id">header-subpage</xsl:attribute>
</prepend>
ID of the header as defined in theme file (header-index) is changed to header-subpage after the rule above is applied.
The rule basically says “Match #header-index element in theme file and use some inline XSL on it”. The “xsl:attribute” tag matches current element’s attribute whose name is “id” (with “current element” being the #header-index element as matched by the outer
Peter Lamut
Peter was one of the original co-founders of Niteo and the main developer on our early projects.