Hello everyone,
I would like to make it possible for list items to display in different colors depending on the subject. The editer of the page should be able to choose out of radio buttons. I have classes and backgrounds set up in my CSS to give the items the styling. Now i want the editor to give a class to a new item.
I havo no experience with XSLT and this is my code whitch i just copied from someone else.
Thanks for the help!!
<?xml version="1.0" encoding="UTF-8"?><!DOCTYPE xsl:stylesheet [ <!ENTITY nbsp “ ”> ]>
<xsl:stylesheet
version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:msxml="urn:schemas-microsoft-com:xslt" xmlns:umbraco.library="urn:umbraco.library" xmlns:Examine="urn:Examine" exclude-result-prefixes="msxml umbraco.library Examine "><xsl:output method=“xml” omit-xml-declaration=“yes”/>
<xsl:param name=“currentPage”/>
<xsl:template match=“/”>
<!-- Root Node --> <xsl:variable name="siteRoot" select="$currentPage/ancestor-or-self::*[@level = 1]" /> <!-- Top --> <ul> <xsl:for-each select="$siteRoot/* [@isDoc and @level = 2 and string(umbracoNaviHide) != '1']"> <li> <xsl:attribute name="class"> <xsl:value-of select="$currentPage/data [@alias = 'Titel']" /> </xsl:attribute> <xsl:if test="HomePageNode/@id = $currentPage/@id"> <xsl:attribute name="class"> <xsl:text>selected</xsl:text> </xsl:attribute> </xsl:if> <!--Create a link to the homepage --> <xsl:value-of select="$currentPage/data[@alias='Titel']" /> <a href="{umbraco.library:NiceUrl(@id)}"> <xsl:value-of select="@nodeName" /> </a> </li> </xsl:for-each> </ul></xsl:template>
</xsl:stylesheet>
This is a companion discussion topic for the original entry at https://our.umbraco.com/forum/57651-letting-the-editor-add-a-class-to-dynamic-list-items