Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Doug Clark 30 posts 52 karma points
    Mar 19, 2010 @ 03:57
    Doug Clark
    0

    simple xslt choose not displaying

    This seems simple enough, but I can't seem to understand why this code isn't working.

    <xsl:choose>
    <xsl:when test="@nodeTypeAlias = 'HomePage'">
    <li class="menu-gap">&nbsp;</li>
    </xsl:when>
    <xsl:otherwise>
    <li class="menu-gap"><a href="/">home</a></li>
    </xsl:otherwise>
    </xsl:choose>

    when I'm on the homepage doc type, it is displaying the code in otherwise. What am I missing?

  • Neil Campbell 58 posts 182 karma points
    Mar 19, 2010 @ 05:48
    Neil Campbell
    0

    Hi Doug,
    It could be that your @nodeTypeAlias is not actually "HomePage" or you may need to do $currentPage/@nodeTypeAlias (depending if your rendering your code in a for-each loop). First try just printing the @nodeTypeAlias to screen out side the conditional statement i.e. <xsl:value-of select="./@nodeTypeAlias" /> and see what come out, then go from there.

    Hope this helps.

    Neil

  • Kim Andersen 1447 posts 2196 karma points MVP
    Mar 19, 2010 @ 08:15
    Kim Andersen
    0

    Hi Doug

    I'd try to put $currentPage in front of your @nodeTypeAlias like this:

    <xsl:choose>
    <xsl:when test="$currentPage/@nodeTypeAlias = 'HomePage'">
    <li class="menu-gap"> </li>
    </xsl:when>
    <xsl:otherwise>
    <li class="menu-gap"><a href="/">home</a></li>
    </xsl:otherwise>
    </xsl:choose>

    This should work in my head. Try it out, and return with your result :)

    /Kim A

  • Doug Clark 30 posts 52 karma points
    Mar 19, 2010 @ 15:03
    Doug Clark
    0

    Thanks Neil and Kim. Both of you were correct. I needed to add $currentPage/.

  • Kim Andersen 1447 posts 2196 karma points MVP
    Mar 19, 2010 @ 20:32
    Kim Andersen
    0

    Perfect Doug!

    Remember to mark this question as solved :)

    Regards,

    /Kim A

Please Sign in or register to post replies

Write your reply to:

Draft