tag:help-archives.hannonhill.com,2010-02-09:/discussions/how-do-i/327-navigation-blockCascade CMS: Discussion 2018-10-18T20:36:11Ztag:help-archives.hannonhill.com,2010-02-09:Comment/51902012011-02-07T21:18:25Z2011-10-25T22:12:47ZNavigation block ???<div><p>Im trying to build a navigation block and I have created the
index block which looks 2 levels deep (top level + second level) no
matter what I try I can only get either the top level folders to
display and not the second level folders or vis versa.</p>
<pre>
<code><ul>
<li id="navhom"><a href="/">Home</a></li>
<xsl:for-each select="//system-folder">
<xsl:variable name="section"><xsl:value-of select="name"/></xsl:variable>
<xsl:variable name="section_div">nav<xsl:value-of select="substring($section,0,4)"/></xsl:variable>
<li id="{$section_div}">
<xsl:choose>
<xsl:when test="descendant::system-folder =''">
No Sub Folders <xsl:value-of select="name"/>
</xsl:when>
<xsl:when test="descendant::system-folder !=''">
With Sub Folders <xsl:value-of select="name"/>
</xsl:when>
</xsl:choose>
</li>
</xsl:for-each>
</ul></code>
</pre>
<p>The code above should build the top level navigation wrapped
with in an UL with the second level navigation wrapped in their own
UL. The second level navigation is written into a hidden div tag
until the top level nav is moused over. Of course if there are no
secondary level navigation I don't want a hidden div to pop up on
mouse over.</p>
<p>Any help on this would be great.. I have a feeling Im just
missing something simple.</p></div>ifordtag:help-archives.hannonhill.com,2010-02-09:Comment/51902012011-02-07T22:40:18Z2011-02-07T22:40:18ZNavigation block ???<div><p>It looks like you're using <code>for-each
select="//system-folder"</code>, which is going to match every
single folder (regardless of depth) and set them as a top-level
list item. Try switching that to just <code>/system-folder</code>
or <code>system-folder</code> instead, without the double
slash.</p></div>Amytag:help-archives.hannonhill.com,2010-02-09:Comment/51902012011-02-07T23:07:23Z2011-10-25T22:12:47ZNavigation block ???<div><p>Amy thank you but the for-each you are talking about needs to
grab all the folders as it is the root for-each to check to see if
there are sub folders or not.</p>
<p>The code below would where I only want to grab the sub folders
for a parent folder.</p>
<pre>
<code><xsl:when test="descendant::system-folder !=''">
<xsl:value-of select="name"/>
<ul>
<xsl:for-each select="system-folder">
<li><a><xsl:attribute name="href">/<xsl:value-of select="name"/>/index.php</xsl:attribute><xsl:value-of select="display-name"/></a></li>
</xsl:for-each>
</ul>
</xsl:when>
</xsl:choose></code>
</pre>
<p>As it still sits I can get the parent and its sub folders but I
can not display any other top level folders if they do not have
secondary folders under them.. Again not sure why this is happening
as I figured the check for</p>
<pre>
<code><xsl:when test="descendant::system-folder =''"></code>
</pre>
<p>would catch any top level folder that does not have any
secondary folders under it but it does not seem to be working like
its suppose to.</p></div>ifordtag:help-archives.hannonhill.com,2010-02-09:Comment/51902012011-02-07T23:09:28Z2011-10-25T22:12:47ZNavigation block ???<div><p>I guess I can't edit posts..<br>
That second loop I should have included in the first code sorry
about that.</p>
<p>Full Code</p>
<pre>
<code><ul>
<li id="navhom"><a href="/">Home</a></li>
<xsl:for-each select="//system-folder">
<xsl:variable name="section"><xsl:value-of select="name"/></xsl:variable>
<xsl:variable name="section_div">nav<xsl:value-of select="substring($section,0,4)"/></xsl:variable>
<li id="{$section_div}">
<xsl:choose>
<xsl:when test="descendant::system-folder =''">
No Sub Folders <xsl:value-of select="name"/>
</xsl:when>
<xsl:when test="descendant::system-folder !=''">
<xsl:value-of select="name"/>
<ul>
<xsl:for-each select="system-folder">
<li><a><xsl:attribute name="href">/<xsl:value-of select="name"/>/index.php</xsl:attribute><xsl:value-of select="display-name"/></a></li>
</xsl:for-each>
</ul>
</xsl:when>
</xsl:choose>
</li>
</xsl:for-each>
</ul></code>
</pre></div>ifordtag:help-archives.hannonhill.com,2010-02-09:Comment/51902012011-02-08T00:01:21Z2011-02-08T00:01:21ZNavigation block ???<div><p>Try the attached XSLT file. Instead of using
<code>for-each</code> loops, I've changed it so that it uses
<code>apply-templates</code>, which I find makes the code easier to
follow.</p>
<p>Another thing to watch out for is to make sure all of your
folder have a <code>display-name</code> filled in, since the code
doesn't currently check for it.</p></div>Amytag:help-archives.hannonhill.com,2010-02-09:Comment/51902012011-02-08T00:04:31Z2011-10-25T22:12:48ZNavigation block ???<div><p>Thank you I will take a look at the xslt.</p>
<p>Correct it does not check for it and I should be a check in for
display-name even though I hope I have trained my users well enough
that they remember to actually fill it in but then again there will
always be one that will forget :)</p>
<p>Thanks again for your help.</p></div>iford