Developer forum

Forum » CMS - Standard features » navigation to show all pages subpages

navigation to show all pages subpages

Jonas Mersholm
Reply

Hi there!

How would i go about creating a dwnavigation tag, which outputs all pages, level 2 pages? Not just the current active level 1 page's subpages? I do not want level 1 or level 3.*

 

Best regards.

Jonas


Replies

 
Mikkel Ricky
Reply

Take a look at startlevel and endlevel in Designs and Layouts [http://developer.dynamicweb-cms.com/documentation/for-designers.aspx]:

<div class="dwnavigation" data-settings="startlevel:2;endlevel:2"></div>

Best regards,
Mikkel

 
Jonas Mersholm
Reply

I'm aware of the start and end level settings, what i would like to achieve, is for the navigation to output ALL level 1 pages subpages. Not just the current, active level 1 page's subpages.

 

Thank you,

Jonas

 
Mikkel Ricky
Reply

Is it "expandmode:all" you're looking for?

 
Jonas Mersholm
Reply

Both yes and no. I am seeking the same behaivour as if expandmode:all were set together with startlevel:1; endlevel:9; ETC.

I just dont want the first level.

 

I am trying to build a fullwidth scrolldown menu, where the user hovers a link, and the submenu will falldown. I want this submenu to contain all page's subpages, and then through javascript deceide which one to show, depending on what link is being hovered.

 

If i set "startlevel:2; endlevel:2; expandmode:all;" - It only renders the subpages to the current active page, and not all page's subpages.

 

I hope it makes sense.

 
Mikkel Ricky
Reply

You can skip the first page level in your xslt:

…
<xsl:template match="NavigationTree">
  <xsl:if test="Page/Page">
    <ul>
      <xsl:apply-templates select="Page/Page"/>
    </ul>
  </xsl:if>
</xsl:template>
…

That should do the trick.

Best regards,
Mikkel

 
Jonas Mersholm
Reply

Thank you Mikkel, this works.

How would you get the "top pages" id in the same context? 

 

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0"  xmlns:xsl="http://www.w3.org/1999/XSL/Transform" >

  <!--
  Description: ul/li based navigation. No features from admin implemented.
  Recommended settings:
  Fold out: True or False
  Upper menu: Dynamic or Static
  First level: > 0
  Last level: >= First level
  -->
  
  <xsl:output method="xml" omit-xml-declaration="yes" indent="yes"  encoding="utf-8" />
  <xsl:param name="html-content-type" />
  <xsl:variable name="iteration" select="1" />

<xsl:template match="/NavigationTree">
  <xsl:if test="Page/Page">
    <ul>
      <xsl:attribute name="class">main-navigation-list</xsl:attribute>
      <xsl:attribute name="data-num">
        <xsl:value-of select="$iteration" disable-output-escaping="yes" />
      </xsl:attribute>
      <xsl:apply-templates select="Page/Page"/>
    </ul>
  </xsl:if>
</xsl:template>

  <xsl:template match="//Page">
    <xsl:param name="depth"/>
    
    <li>
      <xsl:attribute name="data-pageid">
          <xsl:value-of select="@ID" disable-output-escaping="yes" />
      </xsl:attribute>
      <a>
        <xsl:attribute name="class">
        <xsl:if test="@InPath='True'">inpath </xsl:if>
        <xsl:if test="position() = 1">firstitem </xsl:if>
        <xsl:if test="position() = count(//Page)">lastitem </xsl:if>
        <xsl:if test="@Active='True'">activeitem</xsl:if>
</xsl:attribute>
        <xsl:attribute name="href"><xsl:value-of select="@FriendlyHref" disable-output-escaping="yes"/></xsl:attribute>
        <h3><xsl:value-of select="@MenuText" disable-output-escaping="yes"/></h3>
      </a>
    
        <xsl:if test="count(Page)">
            <ul class="M{@AbsoluteLevel}">
              <xsl:apply-templates select="Page">
                <xsl:with-param name="depth" select="$depth+1"/>
              </xsl:apply-templates>
            </ul>
        </xsl:if>

        <xsl:variable name="iteration" select="$iteration+1" />
    </li>
  </xsl:template>

</xsl:stylesheet>

So the result will be
<li data-pageid="1"></li>

<li data-pageid="1"></li>

<li data-pageid="2"></li>

 

Instad of as now, where it takes @ID, which is the current subpages's id?

 
Mikkel Ricky
Reply
This post has been marked as an answer

Get the id from the parent axis [http://www.w3schools.com/xpath/xpath_axes.asp]:

<xsl:value-of select="parent::*/@ID"/>

or

<xsl:value-of select="parent::Page/@ID"/>

 

Votes for this answer: 1

 

You must be logged in to post in the forum