forrest-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Robert Koberg <...@koberg.com>
Subject Re: Flat navigation
Date Sun, 30 Nov 2003 19:50:16 GMT
Hi,

Nicola Ken Barozzi wrote:

> Marshall Roch wrote:
> 
>> Jason End wrote:
>>
>>> For flat links, just put the inside a single "subtag"
>>> of <site>...</site>. Subdirs are only created if you
>>> nest more than one set of tagged entries within
>>> another. 
>>
>>
>> Right, but if I want to use subdirectories without having them in the 
>> nav until you click on their folder, how would I do that?
> 
> 
> I understand what you mean.
> 
> It's one of the things that IMHO should be done by Forrest, and I had 
> also taked about it... well... months ago (which makes me think that I 
> should do more and talk less ;-)
> 
> Please enter a request for enhancement in the Forrest JIRA and assign it 
> to me. If for some reason JIRA doesn't make you assign people, send the 
> id of the "bug" here so I will assign myself to it.
> 

This is one of the reasons (as I have explained in the past, I believe) 
the site.xml should use generic names and IDs as opposed to unique 
element names. It is also useful to provide some metadata attributes as 
well.

When using a name like 'folder' you can use an XSL like (check the 
inline comments for more explanation):

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

   <!-- Start the nav by using the current view's parent folder -->
   <xsl:template name="nav">
     <div id="nav">
       <div class="title">In this section:</div>
       <xsl:apply-templates mode="nav" select="key('site', 
$lsb_folder_id)/*"/>
     </div>
   </xsl:template>

   <xsl:template match="regions | title | label" mode="nav"/>

   <xsl:template match="folder" mode="nav">

   <!-- determine whether this folder should show on the nav -->

     <xsl:if test="@onnav='1'">
       <xsl:variable name="_href">
         <xsl:call-template name="folder_path_builder"/>
       </xsl:variable>
       <xsl:variable name="title">
         <xsl:value-of select="title"/>
       </xsl:variable>
       <xsl:choose>

       <!-- should this folder expand it's contents on the nav? -->

         <xsl:when test="@expand='1'">
           <div class="normal" title="{$title}">
             <div class="expandedFolder">
               <xsl:value-of select="label"/>
             </div>
             <div class="expanded">
               <xsl:apply-templates mode="nav" select="*"/>
             </div>
           </div>
         </xsl:when>

         <!-- if not expanded and not a descendant of the current view's 
parent folder,
         show a link to the folder (actually, the index page) -->

         <xsl:when test="not(@id=$folder_idref or 
descendant::*[@id=$folder_idref])">
           <div class="normal" title="{$title}">
             <a href="{$_href}" title="{$title}">
               <img alt="Links to a section" src="{$relative_path}i/f.gif"/>
               <xsl:value-of select="label"/>
             </a>
           </div>
         </xsl:when>
         <xsl:otherwise>
           <div class="selected">
             <a href="{$_href}" title="{$title}">
               <xsl:text>&#160;&#187;&#160;</xsl:text>
               <xsl:value-of select="label"/>
             </a>
           </div>
         </xsl:otherwise>
       </xsl:choose>
     </xsl:if>
   </xsl:template>

   <xsl:template match="page" mode="nav">

   <!-- determine whether to include this page in the nav
   based on the onnav attribute and if this page is ready to be 
generated -->

     <xsl:if test="@onnav='1' and @generate='1'">
       <xsl:variable name="id" select="@id"/>
       <xsl:variable name="_href">
         <xsl:call-template name="page_path_builder"/>
       </xsl:variable>
       <xsl:variable name="title">
         <xsl:value-of select="title"/>
       </xsl:variable>
       <xsl:choose>

       <!-- determine if this page is the focus view -->

         <xsl:when test="not($id=$page_idref)">
           <div class="normal">
             <a href="{$_href}" title="{$title}">
               <img alt="Links to a page" src="{$relative_path}i/p.gif"/>
               <xsl:value-of select="label"/>
             </a>
           </div>
         </xsl:when>
         <xsl:otherwise>
           <div class="selected">
             <a href="{$_href}" title="{$title}">
               <xsl:text>&#160;&#187;&#160;</xsl:text>
               <xsl:value-of select="label"/>
             </a>
           </div>
         </xsl:otherwise>
       </xsl:choose>
     </xsl:if>
   </xsl:template>

</xsl:stylesheet>



Mime
View raw message