SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Member
    Join Date
    Apr 2005
    Posts
    4
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    :choose different CSS-classes?

    Hi all!

    I have something of a basic question. It seems I was even more out of practice than I thought when I took on this job ...

    The XSLT below generates a menu in the form of an Unordered List. I've managed to make it appear where I want it, but I also need to assign a different .CLASS to each LIst item (1 to 8). Can someone help?

    Code:
    <xsl:template name="MENU"> 
    <!-- Applies the horisontal menu --> 
    <div id="horimeny"> 
    <div id="meny"> 
    <ul> 
    <xsl:apply-templates select="/DOCUMENT/BODY/ARTICLES/ACTION/FOLDERS/*[PARENT = $INTERNETROOT]" mode="MAIN_MENU"/> 
    </ul> 
    </div><!-- END #meny --> 
    </div><!-- END #horimeny --> 
    </xsl:template> 
    
    <xsl:template match="FOLDERS/*" mode="MENU"> 
    <xsl:variable name="url"> 
    <xsl:choose> 
    <xsl:when test="starts-with(LABEL, 'http://')"><xsl:value-of select="LABEL"/></xsl:when> 
    <xsl:otherwise><xsl:value-of select="URL/text()"/></xsl:otherwise> 
    </xsl:choose> 
    </xsl:variable> 
    
    <xsl:variable name="pos" select="count(preceding-sibling::FOLDER[ATTRIBUTES/ATTRIBUTE[LABEL = 'menu_new']/VALUE = 'Horisontalmeny'])"/> 
    
    <li> 
    <xsl:if test="contains($PATH, concat(',', ID, ','))"> 
    <xsl:attribute name="class"> 
    <xsl:text>current</xsl:text> 
    <xsl:if test="$pos = 0 or LABEL = 'home'"><xsl:text> first</xsl:text></xsl:if> 
    <xsl:if test="not(following-sibling::FOLDER[ATTRIBUTES/ATTRIBUTE[LABEL = 'menu_new']/VALUE = 'Horisontalmeny'])"><xsl:text> last</xsl:text></xsl:if> 
    </xsl:attribute> 
    </xsl:if> 
    <!--<xsl:value-of select="$pos"/>--> 
    <a href="{$url}"><span><xsl:apply-templates select="NAME/text()"/></span></a> 
    </li>
    I'd also like to me rid of the submenu here ... I've managed it temporarily by using "display: none" in the CSS, but that's hardly the way to do it!

    I hope someone can help me out -- I'd be ever so greatful

  2. #2
    SitePoint Member
    Join Date
    Apr 2005
    Posts
    4
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I've been told it's a bit hard to understand what I want to achive, so I'll try to explain that more clearly:

    I need an unordered list where each list item can be given a different class, something like this:

    Code:
    <ul>
    <li class="red">Item 1</li>
    <li class="blue">Item 2</li>
    ...
    <li class="yellow">Item 8</li>
    </ul>
    I can generate the unordered list fine, but I haven't figured out yet how to assign a different class to each list item. I hope someone can help me

  3. #3
    SitePoint Member
    Join Date
    Apr 2005
    Posts
    4
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    All solved


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •