[opencms-dev] RE: Dynamic navigation

Frans Postma fpostma at xs4all.nl
Wed Mar 23 10:24:52 CET 2005


Look at the other provided templates, specificly the Welcome one. That one is MUCH simpler, templateOne is a bit to complicated to
learn from :) Check out the file /system/modules/welcome/elements/welcome_nav.jsp which is included from the main template at
/systems/modules/welcome/templates/welcome (which is a jsp-type page).
 
You might also want to read the javadocs on at least org.opencms.jsp.JspActionElement and NavBuilder/NavigationElement classes,
those are what you will use for building menu's.
 
Example pasted below, forgive the lousy formatting due to cut/paste ;-)
 
== welcome_nav.jsp ==
<%@ page import="org.opencms.jsp.*" %><% 
 
    /*      
     * This is a simple example on how to build a dynamic navigation using JSP in OpenCms.
     * It serves the purpose of demonstrating 
     * the general way to build a dynamic navigation using OpenCms resource properties.
     */
     
    // Create a JSP action element
    CmsJspActionElement cms = new CmsJspActionElement(pageContext, request, response);
  
 // Some shortcuts to often used Strings
 String filename = cms.getRequestContext().getUri();
 
 // List of all pages / subfolders (sorted by NavPos property)
 java.util.List list = cms.getNavigation().getNavigationForFolder(); 
    java.util.Iterator i = list.iterator();
 
 // Now build the navigation
 out.println("<p class=\"small\">Navigation: ");
 
    while (i.hasNext()) {
     CmsJspNavElement ne = (CmsJspNavElement)i.next();
  if (! ne.getResourceName().equals(filename)) {      
   out.println("<a href=\"" + 
   cms.link(ne.getResourceName()) + "\">" 
   + ne.getNavText() + "</a>");   
  } else {
   out.println(ne.getNavText());      
  }     
  if (i.hasNext()) {
   out.println(" | ");
  }
    }
 out.println("</p>");   
%>
================
 
Frans



  _____  

From: opencms-dev-bounces at opencms.org [mailto:opencms-dev-bounces at opencms.org] On Behalf Of Vaylee Mckenzie-Daniels
Sent: woensdag 23 maart 2005 9:55
To: opencms-dev at opencms.org
Subject: [opencms-dev] RE: Dynamic navigation


Hi
 
I'm using OpenCms 6, and I struggle  with  building a dynamic navigation. I have looked at templateone, which is extremely
complicated. Can someone please guide me?

 
Thx

Vaylee 

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


More information about the opencms-dev mailing list