You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@forrest.apache.org by Mickael Remond <mi...@erlang-fr.org> on 2005/07/11 19:38:32 UTC

Problem with site.xml and menu for hidden items

Hello,

I have been using Forrest for a while but there is still one thing that 
I do not understand and that I found annoying.
I build a site.xml file. This file contains menu entry that are not show 
(no label attributes). The upper level is shown and provides links in 
the content to the lower level that are not show.

Now, when I click on this not shown sublevel, all the menu entry are 
shown, and not only the menu part for the portion of the site I am 
currently browsing. This is strange as parent level menu is properly 
displayed, but now hidden menu entry, as if Forrest could not know where 
to place page in the menu hierarchy. It is behaving nearly the same as 
if the unshown menu entry was not at all defined in the site.xml file.

Do you have any idea of why this is happening ?
Any workaround idea ?

I am using Forrest 0.6.

-- 
Mickaël Rémond

Re: Problem with site.xml and menu for hidden items

Posted by Diwaker Gupta <di...@apache.org>.
On Wednesday 20 July 2005 7:39 am, Mickael Remond wrote:
> My question is the following: How is it possible to hide link under a
> certain level while keeping a proper rendering of the menu ? Is it
> possible ?

The menu generation is a function of how your site.xml and tabs.xml are 
structured. See:
http://forrest.apache.org/docs_0_70/linking.html#menu_generation

Diwaker
-- 
Web/Blog/Gallery: http://floatingsun.net

Re: Problem with site.xml and menu for hidden items

Posted by Mickael Remond <mi...@erlang-fr.org>.
Ross Gardler wrote:
> Let us know if you get anywhere, a patch would be welcome if you make 
> this work.

Hello again,

Here is how I solved the problem. This is not a perfectly clean hack but 
it works for me ;-)
I used this piece of site.xml code:
       <release type="leaf" label="Release notes" href="releases/"
                description="Latest release notes">
         <index type="hidden" label="Release notes" href="index.html"/>
         <release2 type="hidden" label="Release 0.9.1"
                   href="release_0.9.1.html"/>
         <release1 type="hidden" label="Release 0.9"
                   href="release_0.9.html"/>
       </release>

The "hidden" element are properly placed in the site hierarchy, whereas 
element with no label are ignored.
Then I use the type tag to force the rendering of elements that would be 
considered as menu to menu-item (clickable). The element is thus render 
as a "leaf", while having children element (all are hidden).

And I had to modify the file 
/src/core/context/resources/stylesheets/site2book.xsl to:

   <xsl:template match="*/*">
     <xsl:choose>
       <!-- No label, abandon the whole subtree -->
       <xsl:when test="not(@label)">
       </xsl:when>
       <!-- Below here, everything has a label, and is therefore 
considered "for display" -->

       <!-- No children -> must be a menu item -->
       <!-- Has children, but they are not for display -> menu item -->
       <xsl:when test="count(*) = 0 or count(*) > 0 and (not(*/@label))">
         <menu-item>
           <xsl:copy-of select="@*"/>
         </menu-item>
       </xsl:when>
       <xsl:when test="@type='leaf'">
          <menu-item>
             <xsl:copy-of select="@*"/>
          </menu-item>
       </xsl:when>
       <!-- Anything else is considered a menu -->
       <xsl:otherwise>
         <menu>
           <xsl:copy-of select="@*"/>
           <xsl:apply-templates/>
         </menu>
       </xsl:otherwise>
     </xsl:choose>
   </xsl:template>

I have only added the "leaf" test, in this piece of code.

On problem remains, that I will solve later: The forced leaf element is 
not rendered as selected when I select it directly. It should not be 
hightlighted when a hidden child is selected however.
An example result is here:
http://www.process-one.net/en/projects/ejabberd/releases/release_0.9.1.html

I will fix that after the vacation break.

Thank you all for your help.

-- 
Mickaël Rémond
  http://www.3pblog.net/

Re: Problem with site.xml and menu for hidden items

Posted by Ross Gardler <rg...@apache.org>.
Mickael Remond wrote:
> Ross Gardler wrote:
> 
>> I missed the first part of this thread. Can you please explain why you 
>> want to have items in your navigation tree with no label, it seems 
>> kind of useless since no one will be able to see the navigation link 
>> and therefore will not be able to use it.
> 
> 
> I would like to avoid generating very long or very deep menu, that's why 
> I would like to hide menu elements. The links to those documents are not 
> included in the menu, but directly inside some of the documents managed 
> by the site.
> So why include those document inside the site.xml file should you ask ? 
> Because, that's the only way I found to have the menu render properly. 
> If you load a file which is not defined in the site.xml, then the 
> complete menu is shown and not only the relevant sublevel.

OK, I get it.

Your approach is not the way to do this as it creates an additional 
maintenance overhead in site.xml (there is no need to reference those 
files there).

Furthermore, The skin expects to highlight the currently selected page 
in the menu. If you have it hidden then the skin is not able to do that.

> An illustration of the problem can for example be tested here:
> http://www.process-one.net/en/projects/ejabberd/releases/index.html
> This document content two sublevels documents that I would like to keep 
> hidden in the menu. However, if you click on one of them, the complete 
> menu for all the site is shown.

What do you expect the menu system to show when one of your hidden pages 
is shown? I suppose the higher level menu item, but that seems a little 
counter intuitive since the menu will highlight content that is not 
actually vissible.

It would be possible to hack the skin so that the higher level menu is 
displayed. The bit you are interested in is:

     <xsl:choose>
       <!-- Compare with extensions stripped -->
       <xsl:when test="$node-path = $path-nofrag">
         <xsl:choose>
           <xsl:when test="contains(@href, '#')">
             <xsl:call-template name="selected-anchor"/>
           </xsl:when>
           <xsl:otherwise>
             <xsl:call-template name="selected"/>
           </xsl:otherwise>
         </xsl:choose>
       </xsl:when>
       <xsl:otherwise>
         <xsl:choose>
           <xsl:when test="contains(@href, '#')">
             <xsl:call-template name="unselected-anchor"/>
           </xsl:when>
           <xsl:otherwise>
             <xsl:call-template name="unselected"/>
           </xsl:otherwise>
         </xsl:choose>
       </xsl:otherwise>
     </xsl:choose>

in main/webapp/skins/common/xslt/html/book2menu.xsl

This code compares the node-path in the site.xml file with the path to 
the current file. I guess you need to add a new <xsl:when> in there. 
Something like this (note this is just an idea, I have not tested, nor 
fully considered the implications):

       <xsl:when test="starts-with($node-path, $path-nofrag)">
         <xsl:choose>
           <xsl:when test="contains(@href, '#')">
             <xsl:call-template name="selected-anchor"/>
           </xsl:when>
           <xsl:otherwise>
             <xsl:call-template name="selected"/>
           </xsl:otherwise>
         </xsl:choose>
       </xsl:when>

Let us know if you get anywhere, a patch would be welcome if you make 
this work.

Ross

Re: Problem with site.xml and menu for hidden items

Posted by Mickael Remond <mi...@erlang-fr.org>.
Ross Gardler wrote:
> I missed the first part of this thread. Can you please explain why you 
> want to have items in your navigation tree with no label, it seems kind 
> of useless since no one will be able to see the navigation link and 
> therefore will not be able to use it.

I would like to avoid generating very long or very deep menu, that's why 
I would like to hide menu elements. The links to those documents are not 
included in the menu, but directly inside some of the documents managed 
by the site.
So why include those document inside the site.xml file should you ask ? 
Because, that's the only way I found to have the menu render properly. 
If you load a file which is not defined in the site.xml, then the 
complete menu is shown and not only the relevant sublevel.

An illustration of the problem can for example be tested here:
http://www.process-one.net/en/projects/ejabberd/releases/index.html
This document content two sublevels documents that I would like to keep 
hidden in the menu. However, if you click on one of them, the complete 
menu for all the site is shown.

> Perhaps if we better understood your use case we could help.

I hope I managed to express more clearly my problem.

Thank you !

-- 
Mickaël Rémond

Re: Problem with site.xml and menu for hidden items

Posted by Ross Gardler <rg...@apache.org>.
Mickael Remond wrote:
> Hello David,
> 
> David Crossley wrote:
> 
>> As well as the reference that Diwaker provided, also look
>> at the forrest/site-author for our site.xml
>> e.g. the "tools" section. Something like this might
>> do the trick ...
>>   <release label="Release notes" href="releases/"      
>> description="Latest release notes">
>>     <index href="index.html"/>
>>     <release2 href="release_0.9.1.html"/>
>>     <release1 href="release_0.9.html"/>
>>   </release>
> 
> 
> Thank you for your help.
> I already tried this approach in the site.xml file, but in this case the 
> index.html, release_0.9.1.html and release_0.9.html file are not 
> generated. The reference to "release/" in the release tag is not 
> sufficient to trigger the inclusion of index.html in the global sitemap 
> and thus the dependant files are not generated.
> Maybe if an option could force the generation of pages in sitemap, even 
> if they have no label on it ...

I missed the first part of this thread. Can you please explain why you 
want to have items in your navigation tree with no label, it seems kind 
of useless since no one will be able to see the navigation link and 
therefore will not be able to use it.

Perhaps if we better understood your use case we could help.

Ross

Re: Problem with site.xml and menu for hidden items

Posted by Mickael Remond <mi...@erlang-fr.org>.
David Crossley wrote:
> Wait, you missed something. I sent another reply
> directly after that correcting my obvious error.

Yes. I missed it. Thank you for pointing the problem. I found the 
missing mail in the web archives.

However, this does not solve the problem. Every files are generated, but 
when I access the hidden sublevel, the whole menu is shown.

I will try investigate template modification as Ross Gardler suggests.

Thank you !

-- 
Mickaël Rémond

Re: Problem with site.xml and menu for hidden items

Posted by David Crossley <cr...@apache.org>.
Mickael Remond wrote:
> Hello David,
> 
> David Crossley wrote:
> >As well as the reference that Diwaker provided, also look
> >at the forrest/site-author for our site.xml
> >e.g. the "tools" section. Something like this might
> >do the trick ...

[ snipped my incorrect suggestion ]

> Thank you for your help.
> I already tried this approach in the site.xml file, but in this case the 
> index.html, release_0.9.1.html and release_0.9.html file are not 
> generated. The reference to "release/" in the release tag is not 
> sufficient to trigger the inclusion of index.html in the global sitemap 
> and thus the dependant files are not generated.
> Maybe if an option could force the generation of pages in sitemap, even 
> if they have no label on it ...

Wait, you missed something. I sent another reply
directly after that correcting my obvious error.

David

Re: Problem with site.xml and menu for hidden items

Posted by Mickael Remond <mi...@erlang-fr.org>.
Hello David,

David Crossley wrote:
> As well as the reference that Diwaker provided, also look
> at the forrest/site-author for our site.xml
> e.g. the "tools" section. Something like this might
> do the trick ...
>   <release label="Release notes" href="releases/" 
>      description="Latest release notes">
>     <index href="index.html"/>
>     <release2 href="release_0.9.1.html"/>
>     <release1 href="release_0.9.html"/>
>   </release>

Thank you for your help.
I already tried this approach in the site.xml file, but in this case the 
index.html, release_0.9.1.html and release_0.9.html file are not 
generated. The reference to "release/" in the release tag is not 
sufficient to trigger the inclusion of index.html in the global sitemap 
and thus the dependant files are not generated.
Maybe if an option could force the generation of pages in sitemap, even 
if they have no label on it ...

-- 
Mickaël Rémond

Re: Problem with site.xml and menu for hidden items

Posted by David Crossley <cr...@apache.org>.
David Crossley wrote:
> Mickael Remond wrote:
> > David Crossley wrote:
> > >If you still have trouble, then create an issue in our Issue Tracker
> > >and attach a screenshot to help explain your problem.
> > 
> > The problem can be demonstrated online. For exemple, here is a normal 
> > page that show the correct menu:
> > http://www.process-one.net/en/projects/ejabberd/releases/index.html
> > 
> > If you click on one of the link on the page you reach the following 
> > page, that display all menu entries in every topic/tab.
> > http://www.process-one.net/en/projects/ejabberd/releases/release_0.9.1.html
> > 
> > The corresponding piece of site.xml is something like:
> >       <release label="Release notes" href="releases/index.html" 
> > 
> >                description="Latest release notes">
> >         <index href="releases/index.html"/>
> >         <release2 href="releases/release_0.9.1.html"/>
> >         <release1 href="releases/release_0.9.html"/>
> >       </release>
> 
> As well as the reference that Diwaker provided, also look
> at the forrest/site-author for our site.xml
> e.g. the "tools" section. Something like this might
> do the trick ...
>   <release label="Release notes" href="releases/" 
>      description="Latest release notes">
>     <index href="index.html"/>
>     <release2 href="release_0.9.1.html"/>
>     <release1 href="release_0.9.html"/>
>   </release>

Oops, i misunderstood your issue. Would this do it? ...

  <release label="Release notes" href="releases/index.html" 
     description="Latest release notes"/>
  <release2 href="releases/release_0.9.1.html"/>
  <release1 href="releases/release_0.9.html"/>

David

Re: Problem with site.xml and menu for hidden items

Posted by David Crossley <cr...@apache.org>.
Mickael Remond wrote:
> David Crossley wrote:
> >If you still have trouble, then create an issue in our Issue Tracker
> >and attach a screenshot to help explain your problem.
> 
> The problem can be demonstrated online. For exemple, here is a normal 
> page that show the correct menu:
> http://www.process-one.net/en/projects/ejabberd/releases/index.html
> 
> If you click on one of the link on the page you reach the following 
> page, that display all menu entries in every topic/tab.
> http://www.process-one.net/en/projects/ejabberd/releases/release_0.9.1.html
> 
> The corresponding piece of site.xml is something like:
>       <release label="Release notes" href="releases/index.html" 
> 
>                description="Latest release notes">
>         <index href="releases/index.html"/>
>         <release2 href="releases/release_0.9.1.html"/>
>         <release1 href="releases/release_0.9.html"/>
>       </release>

As well as the reference that Diwaker provided, also look
at the forrest/site-author for our site.xml
e.g. the "tools" section. Something like this might
do the trick ...
  <release label="Release notes" href="releases/" 
     description="Latest release notes">
    <index href="index.html"/>
    <release2 href="release_0.9.1.html"/>
    <release1 href="release_0.9.html"/>
  </release>

David

> My question is the following: How is it possible to hide link under a 
> certain level while keeping a proper rendering of the menu ? Is it 
> possible ?
> 
> Thank you in advance.
> 
> -- 
> Micka?l R?mond

Re: Problem with site.xml and menu for hidden items

Posted by Mickael Remond <mi...@erlang-fr.org>.
David Crossley wrote:
> If you still have trouble, then create an issue in our Issue Tracker
> and attach a screenshot to help explain your problem.

The problem can be demonstrated online. For exemple, here is a normal 
page that show the correct menu:
http://www.process-one.net/en/projects/ejabberd/releases/index.html

If you click on one of the link on the page you reach the following 
page, that display all menu entries in every topic/tab.
http://www.process-one.net/en/projects/ejabberd/releases/release_0.9.1.html

The corresponding piece of site.xml is something like:
       <release label="Release notes" href="releases/index.html" 

                description="Latest release notes">
         <index href="releases/index.html"/>
         <release2 href="releases/release_0.9.1.html"/>
         <release1 href="releases/release_0.9.html"/>
       </release>

My question is the following: How is it possible to hide link under a 
certain level while keeping a proper rendering of the menu ? Is it 
possible ?

Thank you in advance.

-- 
Mickaël Rémond

Re: Problem with site.xml and menu for hidden items

Posted by David Crossley <cr...@apache.org>.
Mickael Remond wrote:
> Hello,
> 
> I have been using Forrest for a while but there is still one thing that 
> I do not understand and that I found annoying.
> I build a site.xml file. This file contains menu entry that are not show 
> (no label attributes). The upper level is shown and provides links in 
> the content to the lower level that are not show.
> 
> Now, when I click on this not shown sublevel, all the menu entry are 
> shown, and not only the menu part for the portion of the site I am 
> currently browsing. This is strange as parent level menu is properly 
> displayed, but now hidden menu entry, as if Forrest could not know where 
> to place page in the menu hierarchy. It is behaving nearly the same as 
> if the unshown menu entry was not at all defined in the site.xml file.
> 
> Do you have any idea of why this is happening ?
> Any workaround idea ?
> 
> I am using Forrest 0.6.

I cannot understand what your problem is. This document was enhanced
for forrest-0.7 to provide some tips ...

http://forrest.apache.org/docs/linking.html#tab-site
http://forrest.apache.org/docs/linking.html#selecting-entries

If you still have trouble, then create an issue in our Issue Tracker
and attach a screenshot to help explain your problem.

-David