Copied to clipboard

Flag this post as spam?

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


  • Raul Roa 18 posts 38 karma points
    Jul 05, 2010 @ 08:15
    Raul Roa
    0

    XSLT - Two level navigation issue

    Hi, I have a two level navigation menu generated with xslt. The thing is I want to output something different than the child nodes for a given doc type on the first level. The code I have is as follows

    <ul class="sf-menu sf-navbar">
          <xsl:for-each select="$currentPage/ancestor-or-self::node [@level=$level]/node [string(data [@alias='umbracoNaviHide']) != '1']">
            <li>
              <a href="#">
                <xsl:value-of select="@nodeName"/>
              </a>
              <!-- Sub pages -->
              <xsl:if test="count(./node) &gt; 0">
                <ul>
                  <xsl:choose>
                    <xsl:when test="$currentPage/ancestor-or-self::node/@$nodeTypeAlias = 'Catalog'">
                      <li>Catalog!!</li>
                    </xsl:when>
                    <xsl:otherwise>
                      <xsl:for-each select="./node">
                        <li>
                          <xsl:if test="$currentPage/ancestor-or-self::node/@id = current()/@id">
                            <xsl:attribute name="class">current</xsl:attribute>
                          </xsl:if>
                          <a href="{umbraco.library:NiceUrl(@id)}">
                            <xsl:value-of select="@nodeName"/>
                          </a>
                          <a>
                            <xsl:value-of select="$currentPage/ancestor-or-self::node/@id"/>
                          </a>
                        </li>
                      </xsl:for-each>
                    </xsl:otherwise>
                  </xsl:choose>
                </ul>
              </xsl:if>
              <!-- End Sub pages -->
            </li>
          </xsl:for-each>
        </ul>

    where I want to only output a li element when I find a Catalog doc type instead of its childs.

  • Kim Andersen 1447 posts 2197 karma points MVP
    Jul 05, 2010 @ 08:51
    Kim Andersen
    0

    If I understand you right, you only want to create the 2nd level navigation when the document type is not a Catalog, am I right?

    If thats the case you could probably try to change your if-statement to something like this:

    <!-- Sub pages -->
             
    <xsl:if test="count(./node) &gt; 0 and ./@nodeTypeAlias!='Catalog'">

    I haven't tested the above code, but when the 1st level node is of the document type 'Catalog' (this name should match the text in the Alias-field on the doc type), there won't be created any 2nd level navigation.

    Hope this works.

    /Kim A

  • Kim Andersen 1447 posts 2197 karma points MVP
    Jul 05, 2010 @ 08:54
    Kim Andersen
    0

    Ahh just took another look at your code, and I think I misunderstod the question.

    You want to create a <li>-element with "Catalog!!!" inside instead of all the children right?

    Try this instead:

    <xsl:when test="./@nodeTypeAlias = 'Catalog'">
    <li>Catalog!!</li>
    </xsl:when>

    /Kim A

  • Raul Roa 18 posts 38 karma points
    Jul 05, 2010 @ 13:20
    Raul Roa
    0

    Hi Kim,

    You were right on your second guess about what's my intention. But even with your suggestion the code does not work. It's like the condition is never valid.

    Thanks in advance

  • Kim Andersen 1447 posts 2197 karma points MVP
    Jul 05, 2010 @ 21:08
    Kim Andersen
    0

    Hmm, you have to remember the if-statement. Does the page contain any subnodes at all?

    Yout could try debugging a little by just writing something inside the if-statement. Just write some text to see if that is rendered. If it is, you now that it's not the if-sentence that's the problem.

    And could you doublecheck that the alias of the Catalog-document type is called "Catalog". Just to be absolutely sure :)

    /Kim A

  • Raul Roa 18 posts 38 karma points
    Jul 06, 2010 @ 16:21
    Raul Roa
    0

    Hi Kim,

    Thanks for your help. The problem was in the if-statement like you said.

Please Sign in or register to post replies

Write your reply to:

Draft