tag:help-archives.hannonhill.com,2010-02-09:/discussions/xslt-formats/6240-adding-subgroup-in-table-of-contents-pageCascade CMS: Discussion 2015-09-24T12:46:30Ztag:help-archives.hannonhill.com,2010-02-09:Comment/378715512015-09-08T14:20:43Z2015-09-08T14:20:43ZAdding subgroup in Table of Contents page<div><p>On one of our microsites we have a Table of Contents page that
indexes through folders pulling out the articles within their own
folder. However one of the folders, by its nature, has far more
articles than the others and we would like to create some kind of
sub-grouping under this folder to organize it more. <a href="http://www.scranton.edu/alumni/journal/issues/2015/spring/contents/index.html">
Here's the page in question</a> with One the Commons being the
folder with the most articles.</p>
<p>My idea is to add another folder within the On The Commons
folder and then create a styling that's different but will sit
underneath the One The Commons information on the TOC. I attached
an image where you can see the fold <code>test</code> within On The
Commons.</p>
<p>I think the only thing I would need to do is add code to the
format to display folder content that's a child of the main folder
groups but I'm not sure how to accomplish that. Here's the format
that creates the TOC, how do I add a conditional that, when there's
a subfolder, will display the content under the main folder?</p>
<pre>
<code><xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:output indent="yes" method="xml"/>
<xsl:variable name="issues-base">/alumni/journal/issues/</xsl:variable>
<xsl:variable name="root-folder">
<xsl:value-of select="concat($issues-base,substring-before(substring-after(//system-page[@current='true']/path,$issues-base),'/'),'/',substring-before(substring-after(substring-after(//system-page[@current='true']/path,substring-before(substring-after(//system-page[@current='true']/path,$issues-base),'/')), '/'), '/'), substring-before(substring-after(substring-after(//system-page[@current='true']/path, substring-before(substring-after(substring-after(//system-page[@current='true']/path,substring-before(substring-after(//system-page[@current='true']/path,$issues-base),'/')), '/'), '/')), $issues-base),'/'))"/>
</xsl:variable>
<xsl:variable name="default-page-name">index</xsl:variable>
<xsl:template match="system-index-block">
<xsl:variable name="root-folder">
<xsl:for-each select="//system-page[@current='true']/ancestor::system-folder">
<xsl:if test="position() = 2">
<xsl:value-of select="path"/>
</xsl:if>
</xsl:for-each>
</xsl:variable>
<div class="contentsArticleSection message"><a href="[system-asset]{$root-folder}/contents/presidents-message[/system-asset]">A Message from the President</a></div>
<xsl:apply-templates mode="root-folder" select="//system-folder[path = $root-folder]"/>
</xsl:template>
<xsl:template match="system-folder" mode="root-folder">
<xsl:apply-templates mode="top-level" select="system-folder[display-name!=''] | system-page[display-name != '' and name != 'index' and name != 'presidents-message'] | system-symlink[name != '']"/>
</xsl:template>
<xsl:template match="system-folder[display-name != ''] | system-page[display-name != '' and name != 'index' and name != 'presidents-message'] | system-symlink[name != '']" mode="top-level">
<xsl:param name="root-folder"/>
<h2 class="contentsArticleTitle col-lg-12 col-md-12 col-sm-12 col-xs-12">
<a>
<xsl:choose>
<xsl:when test="name(.) = 'system-symlink'">
<xsl:attribute name="href"><xsl:value-of select="link"/></xsl:attribute>
<xsl:attribute name="title"><xsl:value-of select="name"/></xsl:attribute>
<xsl:value-of select="name"/>
</xsl:when>
<xsl:otherwise>
<xsl:attribute name="href">
<xsl:value-of select="path"/>
<xsl:if test="name(.)='system-folder'">/<xsl:value-of select="$default-page-name"/></xsl:if>
</xsl:attribute>
<xsl:attribute name="title"><xsl:value-of select="display-name"/></xsl:attribute>
<xsl:value-of select="display-name"/>
</xsl:otherwise>
</xsl:choose>
</a>
</h2>
<xsl:for-each select="descendant::system-page[name!='index' and name != 'presidents-message' and display-name != ''] | descendant::system-symlink[name!='']">
<div class="contentsArticleSection pos1 col-lg-6 col-md-6 col-sm-6 col-xs-12">
<xsl:if test="position() mod 2 = 0"><xsl:attribute name="class">contentsArticleSection pos2 col-lg-5 col-md-5 col-sm-5 col-xs-12</xsl:attribute></xsl:if>
<div class="contentsArticleContent">
<xsl:if test="not(contains(display-name, 'A Message from the President'))">
<a>
<xsl:choose>
<xsl:when test="name(.) = 'system-symlink'">
<xsl:attribute name="href"><xsl:value-of select="link"/></xsl:attribute>
<xsl:attribute name="title"><xsl:value-of select="name"/></xsl:attribute>
<xsl:value-of select="name"/>
</xsl:when>
<xsl:otherwise>
<xsl:attribute name="href">
<xsl:value-of select="path"/>
</xsl:attribute>
<xsl:attribute name="title"><xsl:value-of select="display-name"/></xsl:attribute>
<xsl:value-of select="display-name"/>
</xsl:otherwise>
</xsl:choose>
</a>
</xsl:if>
</div>
</div>
</xsl:for-each>
</xsl:template>
</xsl:stylesheet></code>
</pre></div>matthew.wrentag:help-archives.hannonhill.com,2010-02-09:Comment/378715512015-09-15T13:30:51Z2015-09-15T13:30:51ZAdding subgroup in Table of Contents page<div><p>Hi Matthew,</p>
<p>I didn't have a chance to test any of this out, but perhaps what
you can do is replace the <code><xsl:for-each></code> with an
<code><xsl:apply-templates></code> and create two new
templates, one for this new folder and one to output those pages
and symlinks (ie the current code within the loop.</p>
<p>In theory, something like the following:</p>
<pre>
<code><xsl:template match="system-folder[display-name != ''] | system-page[display-name != '' and name != 'index' and name != 'presidents-message'] | system-symlink[name != '']" mode="top-level">
<xsl:param name="root-folder"/>
<h2 class="contentsArticleTitle col-lg-12 col-md-12 col-sm-12 col-xs-12">
<a>
<xsl:choose>
<xsl:when test="name(.) = 'system-symlink'">
<xsl:attribute name="href"><xsl:value-of select="link"/></xsl:attribute>
<xsl:attribute name="title"><xsl:value-of select="name"/></xsl:attribute>
<xsl:value-of select="name"/>
</xsl:when>
<xsl:otherwise>
<xsl:attribute name="href">
<xsl:value-of select="path"/>
<xsl:if test="name(.)='system-folder'">/<xsl:value-of select="$default-page-name"/></xsl:if>
</xsl:attribute>
<xsl:attribute name="title"><xsl:value-of select="display-name"/></xsl:attribute>
<xsl:value-of select="display-name"/>
</xsl:otherwise>
</xsl:choose>
</a>
</h2>
<xsl:apply-templates select="descendant::system-folder[display-name != ''] | descendant::system-page[name!='index' and name != 'presidents-message' and display-name != ''] | descendant::system-symlink[name!='']" mode="sub-level"/>
</xsl:template>
<xsl:template match="system-folder[display-name != '']" mode="sub-level">
... Output custom stuff here ...
</xsl:template>
<xsl:template match="system-page[name!='index' and name != 'presidents-message' and display-name != ''] | system-symlink[name!='']" mode="sub-level">
<div class="contentsArticleSection pos1 col-lg-6 col-md-6 col-sm-6 col-xs-12">
<xsl:if test="position() mod 2 = 0"><xsl:attribute name="class">contentsArticleSection pos2 col-lg-5 col-md-5 col-sm-5 col-xs-12</xsl:attribute></xsl:if>
<div class="contentsArticleContent">
<xsl:if test="not(contains(display-name, 'A Message from the President'))">
<a>
<xsl:choose>
<xsl:when test="name(.) = 'system-symlink'">
<xsl:attribute name="href"><xsl:value-of select="link"/></xsl:attribute>
<xsl:attribute name="title"><xsl:value-of select="name"/></xsl:attribute>
<xsl:value-of select="name"/>
</xsl:when>
<xsl:otherwise>
<xsl:attribute name="href">
<xsl:value-of select="path"/>
</xsl:attribute>
<xsl:attribute name="title"><xsl:value-of select="display-name"/></xsl:attribute>
<xsl:value-of select="display-name"/>
</xsl:otherwise>
</xsl:choose>
</a>
</xsl:if>
</div>
</div>
</xsl:template></code>
</pre></div>Ryan Griffith