[opencms-dev] dealing with changing NavTreeLevel

Nigel Kersten nigel at cofa.unsw.edu.au
Mon Aug 29 00:16:43 CEST 2005


On 29/08/2005, at 6:17 AM, Nigel Kersten wrote:
> it was confusing us how when building a hierarchical menu, the  
> NavTreeLevel of "/sites/cofa" would be different whether you were  
> previewing the Offline project while logged in, or looking at the  
> Online project as a web user.
>
> This is how we got around it, and then we build the hierarchical  
> menu based upon this cofaRootNavLevel:
>
> java.util.List findCofaList = cms.getNavigation 
> ().getNavigationBreadCrumb();
> java.util.Iterator fn = findCofaList.iterator();
> while (fn.hasNext())
> {
>     CmsJspNavElement fne = (CmsJspNavElement)fn.next();
>     if (fne.getFileName().equals("cofa/"))
>     {
>     cofaRootNavLevel = fne.getNavTreeLevel();
>     }
> }
>
> But I'm just wondering if there is a more elegant method that  
> people often use to distinguish between the two cases?

To make it clearer, I'm pretty sure I should be able to just  
interrogate directly "/sites/cofa" to find out what it's NavTreeLevel  
is, but I don't seem to be able to work out from the API what I use  
to do this.

I thought I could just do something like:

CmsJspNavElement cofaRoot = cms.getNavigation 
().getNavigationForResource("/sites/cofa/index.html");
int newRootNav = cofaRoot.getNavTreeLevel();

but I'm obviously passing the wrong kind of parameter to  
getNavigationForResource or Folder or whichever one I try.



--
Nigel Kersten [Senior Technical Officer]
College of Fine Arts, University of NSW, Australia.
CRICOS Provider Code: 00098G





More information about the opencms-dev mailing list