Copied to clipboard

Flag this post as spam?

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


  • Fuji Kusaka 2203 posts 4220 karma points
    May 06, 2012 @ 14:42
    Fuji Kusaka
    0

    Positioning SubNav depending on the Parent Node

    Hi,

    How can i get to display a SubNavigation depending on the Parent Node Position. What i need to do is be able to start my Sub Nav on the same top position as the Parent.

    I try something like that but am messing up my xslt here

    <xsl:variable name="level" select="4"/>
        <xsl:variable name="nodes" select="$currentPage/ancestor-or-self::* [@level=$level]/* [@isDoc and string(umbracoNaviHide) != '1']" />
    <xsl:template match="/">
    <!-- The fun starts here -->
    <xsl:for-each select="$nodes">  
      
    <xsl:choose>
    <xsl:when test="position ()= 2">
    <xsl:call-template name="firstNode" />
    </xsl:when>
    <xsl:otherwise>
      <xsl:call-template name="secondNode" />
    </xsl:otherwise>
    </xsl:choose>     
      
    </xsl:for-each>

    </xsl:template>
  • Jan Skovgaard 11258 posts 23500 karma points MVP 7x admin c-trib
    May 06, 2012 @ 15:01
    Jan Skovgaard
    0

    Hi Fuji

    Could you show a website example of the effect you're trying to achieve? Think it's easier to grasp the essence of the question if there is a visual desired end result to look at.

    /Jan

  • Fuji Kusaka 2203 posts 4220 karma points
    May 06, 2012 @ 17:18
    Fuji Kusaka
    0

    Hi Jan,

    Well very simple my content tree section looks like this 

    Content
    -Home 
    -- Products
    --- Product Cat 1
    --Item 1
    --Item 2
    --Item 3
    --- Product Cat 2
    --Item 1
    --Item 2
    --- Product Cat 3 
    --- Donwloads
    --- Contacts
    --- etc

    So what needs to be done here is when i am on Product Cat 1 its subContent displays in a <ul> with  a top position and if am on Product 2 it displays with a different top position .

    //fuji 

  • Fuji Kusaka 2203 posts 4220 karma points
    May 06, 2012 @ 20:22
    Fuji Kusaka
    0

    In other words Sub Navigation will display depending on the Parent Node Position. 

    If Parent Node has a Position () = 1 the Sub Navi will have a certaint top position and if Position() = 2 a different one.

     

     

  • Jan Skovgaard 11258 posts 23500 karma points MVP 7x admin c-trib
    May 18, 2012 @ 18:12
    Jan Skovgaard
    0

    Hi Fuji

    Sorry for my late reply - did you manage to fix this?

    The way I understand your issue is that it's about displaying the nodes on the website with CSS, right? It's not neccesary a matter of the code structure, is it?

    Sounds like you need to render a nested list of elements and then have elements of a certain level displayed in a certain way?

    /Jan

  • Fuji Kusaka 2203 posts 4220 karma points
    May 18, 2012 @ 21:38
    Fuji Kusaka
    0

    Hi Jan,

    Yes in fact i needed to check if parent has child nodes and if its the first parent node does display  the child node with a top position and if not with another position.

    Well instead of XSLT i did it in Razor. Here is how i got it solved out.

    @using umbraco.MacroEngines;
    @inherits umbraco.MacroEngines.DynamicNodeContext

    @{
     
     var parent = Model.AncestorOrSelf(4);  
      const string selectedClass = " class=\"current\"";
      
      
      if(parent !=null){        
                     <ul id="subPage" style="top:@parent.IsFirst("58px","95px")">
                     @foreach(var item in parent.Children.Where("Visible")){                                                                        
                             <li@Library.If(item.IsAncestorOrSelf(Model), selectedClass)><a href="@item.Url">@item.Name</a></li>
                      }
                      </ul> 
           }
      
    }
     

    //fuji

  • 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