[opencms-dev] Navigation: Is nav item current page?

Thorsten Duhn duhn at regio-gmbh.de
Fri Jan 22 13:46:25 CET 2016


Hello,

as I have rewritten navigation creation I wanted a better detection if 
an nav item is the currently requested page. I had some problems using 
"startsWith" like in example Bootstrap template code, I don't want the 
parent folders containing current item to be marked as well.

So I made this more strict one:

boolean _isCurrent(CmsJspActionElement cms, CmsJspNavElement elem) {
     if ((cms != null) && (elem != null)) {
         String uri = (elem.isFolderLink()) ? 
cms.getRequestContext().getFolderUri() : cms.getRequestContext().getUri();
         if (uri != null) {
             return uri.equals(elem.getResourceName());
         }
     }
     return false;
}

What is missing now is the one exception from the rule, on detail pages 
I surely want to mark the upper level (the list page) as current. Any 
hint how I can find out that current uri is to a detail page?

Regards,
Thorsten

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://webmail.opencms.org/pipermail/opencms-dev/attachments/20160122/1f7c92e9/attachment.htm>


More information about the opencms-dev mailing list