Products

Solutions

Resources

Partners

Community

Blog

About

QA

Ideas Test

New Community Website

Ordinarily, you'd be at the right spot, but we've recently launched a brand new community website... For the community, by the community.

Yay... Take Me to the Community!

Welcome to the DNN Community Forums, your preferred source of online community support for all things related to DNN.
In order to participate you must be a registered DNNizen

HomeHomeUsing DNN Platf...Using DNN Platf...Skins, Themes, ...Skins, Themes, ...Superfish XLST question - applying a class to alternating items? Superfish XLST question - applying a class to alternating items?
Previous
 
Next
New Post
2/3/2012 1:11 PM
 
Is it possible to add a class to alternating list items when using the DDR Superfish template? My designer gave me the following:



The one thing that I am having issues implementing is the 2 alternating shades of yellow and then the alternating gray and white in the submenu. I have customized my XLST file a bit already. Can someone take a peek below and offer any suggestions?

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
    <xsl:output method="html"/>
    <xsl:param name="ControlID" />
    <xsl:param name="Options" />
    <xsl:template match="/*">
        <xsl:apply-templates select="root" />
    </xsl:template>
    <xsl:template match="root">
        <script type="text/javascript">
            jQuery(function($) {
            $("#<xsl:value-of select="$ControlID" />").superfish(
            <xsl:value-of select="$Options" />
            );
            });
        </script>
        <ul class="sf-menu level1" id="{$ControlID}">
            <xsl:apply-templates select="node" />
        </ul>
    </xsl:template>
    <xsl:template match="node">
        <li>
            <xsl:attribute name="class">
                <xsl:if test="@first = 1">first</xsl:if>
                <xsl:if test="@last = 1">
                    <xsl:text> </xsl:text>last
                </xsl:if>
                <xsl:if test="@selected = 1">
                    <xsl:text> </xsl:text>selected
                </xsl:if>
            </xsl:attribute>
            <span>
            <a>
                <xsl:choose>
                    <xsl:when test="@enabled = 1">
                        <xsl:attribute name="href">
                            <xsl:value-of select="@url"/>
                        </xsl:attribute>
                    </xsl:when>
                    <xsl:otherwise>
                        <xsl:attribute name="href">#</xsl:attribute>
                        <xsl:attribute name="onclick">return false</xsl:attribute>
                    </xsl:otherwise>
                </xsl:choose>
                <xsl:value-of select="@text" />
            </a>
            </span>
            <xsl:if test="node">
                <ul class="level{@depth + 2}">
                    <xsl:apply-templates select="node" />
                </ul>
            </xsl:if>
        </li>
    </xsl:template>
</xsl:stylesheet>
 
New Post
2/3/2012 1:35 PM
 

you can do this via the level parameter (http://www.dotnetnuke.com/Resources/W... has some examples) -in this case you can either do 2 IF tests (as annoying xslt IF does not support ELSE) or use xsl:choose e.g.

<xsl:if test="level mod 2 = 1)">
...
 </xsl:if>
<xsl:if test="level mod 2 = 0)">
...
 </xsl:if>

or

<xsl:choose>
  <xsl:when test="condition">
    <!-- if condition -->
  </xsl:when>
  <xsl:otherwise>
    <!-- else condition -->
  </xsl:otherwise>
</xsl:choose>


Buy the new Professional DNN7: Open Source .NET CMS Platform book Amazon US
 
New Post
2/3/2012 1:36 PM
 

oh, should have mentioned, you don't need to vary the whole tag, just the attribute e.g.

<xsl:if test="(level mod 2 = 1)">
 <xsl:attribute name = "style">firststyle</xsl:attribute>
 </xsl:if>


Buy the new Professional DNN7: Open Source .NET CMS Platform book Amazon US
 
New Post
2/3/2012 3:36 PM
 

Hi cathal,

Thanks for the quick reply. I tried out several variations of your code and couldn't quite get it to work. After a bit of searching around, I settled on adding the below and it now adds a class called "alternate" to every other list item (with a space before to separate it from the other classes). Thanks so much for pointing me in the right direction.

<xsl:if test="position() mod 2 != 1">
    <xsl:attribute name="class">
        <xsl:text> </xsl:text>alternate
    </xsl:attribute>
</xsl:if>
 
Previous
 
Next
HomeHomeUsing DNN Platf...Using DNN Platf...Skins, Themes, ...Skins, Themes, ...Superfish XLST question - applying a class to alternating items? Superfish XLST question - applying a class to alternating items?


These Forums are dedicated to discussion of DNN Platform and Evoq Solutions.

For the benefit of the community and to protect the integrity of the ecosystem, please observe the following posting guidelines:

  1. No Advertising. This includes promotion of commercial and non-commercial products or services which are not directly related to DNN.
  2. No vendor trolling / poaching. If someone posts about a vendor issue, allow the vendor or other customers to respond. Any post that looks like trolling / poaching will be removed.
  3. Discussion or promotion of DNN Platform product releases under a different brand name are strictly prohibited.
  4. No Flaming or Trolling.
  5. No Profanity, Racism, or Prejudice.
  6. Site Moderators have the final word on approving / removing a thread or post or comment.
  7. English language posting only, please.
What is Liquid Content?
Find Out
What is Liquid Content?
Find Out
What is Liquid Content?
Find Out