Developer forum

Forum » Templates » List groups in navigation

List groups in navigation

Kasper Skov
Reply

I've seen the sticky post on ecom navigation, but none of the examples accomplishes what I want.

I am currently using a slightly modified xslt navigation that came with the solutionset/bikeshop/demosite thingo. If I enable the setting that list my groups in the navigation through the advanced page settings>navigation, the first level of groups simply lists along side with the rest of the root pages.

I would like all of my groups, no matter what level, to be listed in the drop down under the product page. Like this:

Webshop

     - Group 1

     - Group 2

     - Subgroup 1

Page 2

      - Subpage1

Page 3

      - Subpage2

 

Any help on the way will be much appreciated. I've attached the xslt im using. I am kindda hopeing that the one of the templates provided by Nicolai in the sticky post combined with the right settings will do the trick :)

 


Replies

 
Mikkel Ricky
Reply

If I understand you correctly, you just have to change the xslt to not wrap eCom subgroups in a new list (<ul/>). This simple xslt illustrates how this can be done (note I'm using the Type attribute introduced in Dynamicweb 8.4):

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0"  xmlns:xsl="http://www.w3.org/1999/XSL/Transform" >
  <xsl:output method="xml" omit-xml-declaration="yes" indent="yes"  encoding="utf-8" />

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

  <xsl:template match="Page">
    <li>
      <a>
                <xsl:variable name="classNames">
                    <xsl:if test="@InPath = 'True'"> inpath </xsl:if>
                    <xsl:if test="@Active = 'True'"> activeitem </xsl:if>
                </xsl:variable>
                <xsl:if test="normalize-space($classNames)">
                    <xsl:attribute name="class">
                        <xsl:value-of select="normalize-space($classNames)"/>
                    </xsl:attribute>
                </xsl:if>
                <xsl:attribute name="href"><xsl:value-of select="@FriendlyHref" disable-output-escaping="yes"/></xsl:attribute>
        <xsl:value-of select="@MenuText" disable-output-escaping="yes"/>
      </a>

            <xsl:if test="Page">
                <xsl:choose>
                    <!-- Don't wrap Ecom groups in a new list (<ul/>) -->
                    <xsl:when test="@Type = 'group'">
                        <xsl:apply-templates select="Page"/>
                    </xsl:when>
                    <xsl:otherwise>
                        <ul>
                            <xsl:apply-templates select="Page"/>
                        </ul>
                    </xsl:otherwise>
                </xsl:choose>
            </xsl:if>
        </li>
  </xsl:template>
</xsl:stylesheet>

Best regards,
Mikkel

 

You must be logged in to post in the forum