Copied to clipboard

Flag this post as spam?

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


  • Neil Norpa 24 posts 44 karma points
    Apr 12, 2011 @ 22:27
    Neil Norpa
    0

    Child / Parent Side Navigation

    Hi i currently has a side navigation which renders the children of the current node

    But..

    i occationaly get a current node which has no children and end up with an empty sidenavigation

    What i need is a sidenavigation which if the it has no children renders all the nodes on the same level as the current node

     

    ie

    home

    -----services

    --------------service a

    --------------service b

    --------------service c

    -----contact

    ----Products

    --------------Product a

    --------------Product b

    --------------Product c

     

    so if i were on the services page

    services a b and c would render

    for contact(no children) if render services and products

    products

    product a b and c would render

     

    this is my current xslt

    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE xsl:stylesheet [ <!ENTITY nbsp "&#x00A0;"> ]>
    <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:Exslt.ExsltCommon="urn:Exslt.ExsltCommon" xmlns:Exslt.ExsltDatesAndTimes="urn:Exslt.ExsltDatesAndTimes" xmlns:Exslt.ExsltMath="urn:Exslt.ExsltMath" xmlns:Exslt.ExsltRegularExpressions="urn:Exslt.ExsltRegularExpressions" xmlns:Exslt.ExsltStrings="urn:Exslt.ExsltStrings" xmlns:Exslt.ExsltSets="urn:Exslt.ExsltSets"
      exclude-result-prefixes="msxml umbraco.library Exslt.ExsltCommon Exslt.ExsltDatesAndTimes Exslt.ExsltMath Exslt.ExsltRegularExpressions Exslt.ExsltStrings Exslt.ExsltSets ">


    <xsl:output method="xml" omit-xml-declaration="yes"/>

    <xsl:param name="currentPage"/>

    <xsl:template match="/">

    <!-- The fun starts here -->
    <ul class="section menu">
    <xsl:for-each select="$currentPage/* [@isDoc and string(umbracoNaviHide) != '1']">
     <li>
      <a href="{umbraco.library:NiceUrl(@id)}">
       <xsl:value-of select="@nodeName"/>
      </a>
     </li>
    </xsl:for-each>
    </ul>

    </xsl:template>
    </xsl:stylesheet>

     

    please help my minds gone to mush

     

     

     

  • Kim Andersen 1447 posts 2197 karma points MVP
    Apr 12, 2011 @ 23:01
    Kim Andersen
    0

    Hi Neil

    Could you maybe try something like this:

    <xsl:template match="/">

    <!-- The fun starts here -->
    <ul class="section menu">
     
    <xsl:choose>
       
    <xsl:when test="count($currentPage/* [@isDoc and string(umbracoNaviHide) != '1']) &gt; 0">
         
    <xsl:apply-templates select="$currentPage/* [@isDoc and string(umbracoNaviHide) != '1']"></xsl:apply-templates>
       
    </xsl:when>
       
    <xsl:otherwise>
         
    <xsl:apply-templates select="$currentPage/../* [@isDoc and string(umbracoNaviHide) != '1']"></xsl:apply-templates>
       
    </xsl:otherwise>
     
    </xsl:choose>
    </ul>

    </xsl:template>

    <xsl:template match="* [@isDoc and string(umbracoNaviHide) != '1']">
     
    <li>
     
    <a href="{umbraco.library:NiceUrl(@id)}">
       
    <xsl:value-of select="@nodeName"/>
     
    </a>
     
    </li>
    </xsl:template>

    /Kim A

  • Neil Norpa 24 posts 44 karma points
    Apr 13, 2011 @ 07:01
    Neil Norpa
    0

    No Joy :(

     

    its not rendering anything, i think its had an issue with there being two when closing tags

     

    thanks for trying.

    </xsl:when>
  • Neil Norpa 24 posts 44 karma points
    Apr 13, 2011 @ 07:06
    Neil Norpa
    0

    changed to this still nothing





    <xsl:template match="/">

    <!-- The fun starts here -->
    <ul class="section menu">
      <xsl:choose>
        <xsl:when test="count($currentPage/* [@isDoc and string(umbracoNaviHide) != '1']) &gt; 0">
          <xsl:apply-templates select="$currentPage/* [@isDoc and string(umbracoNaviHide) != '1']"></xsl:apply-templates>
        </xsl:when>
        <xsl:otherwise>
          <xsl:apply-templates select="$currentPage/../* [@isDoc and string(umbracoNaviHide) != '1']"></xsl:apply-templates>
        </xsl:otherwise>
      </xsl:choose>
    </ul>

    </xsl:template>

    <xsl:template match="* [@isDoc and string(umbracoNaviHide) != '1']">
     <li>
      <a href="{umbraco.library:NiceUrl(@id)}">
       <xsl:value-of select="@nodeName"/>
      </a>
     </li>
    </xsl:template>

  • Ove Andersen 435 posts 1541 karma points c-trib
    Apr 13, 2011 @ 10:24
    Ove Andersen
    0

    This should work:

    <xsl:template match="/">
    
    <!-- The fun starts here -->
    <ul class="section menu"> <xsl:choose> <xsl:when test="$currentPage/* [@isDoc and string(umbracoNaviHide) != '1']">
    <xsl:for-each select="$currentPage/* [@isDoc and string(umbracoNaviHide) != '1']"> <xsl:call-template name="listitem"> <xsl:with-param name="node" select="current()">
    </xsl:call-template> </xsl:for-each> </xsl:when> <xsl:otherwise> <xsl:for-each select="$currentPage/../* [@isDoc and string(@id) != string($currentPage/@id) and string(umbracoNaviHide) != '1']"> <xsl:call-template name="listitem"> <xsl:with-param name="node" select="current()"> </xsl:call-template>
    </xsl:for-each> </xsl:otherwise> </xsl:choose> </ul> </xsl:template> <xsl:template name="listitem">
        <xsl:param name="node" />

        <li>
    <a href="{umbraco.library:NiceUrl($node/@id)}"> <xsl:value-of select="$node/@nodeName"/> </a>
        </li>
    </xsl:template>
  • Neil Norpa 24 posts 44 karma points
    Apr 19, 2011 @ 23:19
    Neil Norpa
    0

    This worked a treat, cheers. you truely are the stuff of legend.

     

    Thanks.

  • This forum is in read-only mode while we transition to the new forum.

    You can continue this topic on the new forum by tapping the "Continue discussion" link below.

Please Sign in or register to post replies