[opencms-dev] getSiteNavigation() does work offline but not online.
Hossfeld, Felix
Felix.Hossfeld at bonprix.net
Thu Nov 3 18:17:24 CET 2005
Hello!
Just a quick question from a newbie:
I create a javascript tree of our intranet site dynamically using the
CmsJspNavBuilder like this
cms.getNavigation().getSiteNavigation("/sites/mysite/",99).
This works fine for the offline project. However, if I want to few the
online version the returned list is empty. I tried changing the
"/sites/mysite/" to "/" but this does not seem to make a difference. The
breadcrumbs method is not working either.
Does anybody have an idea why?
Thanks
Felix
P.S.: My code looks like this:
<%@ page import="java.util.List, java.util.Iterator,
java.util.Hashtable, java.lang.Integer" %>
<div class="navtree">
<%
String rootFolder = "/sites/mysite/";
// "/" does not work either!!
// Create a JSP action element
org.opencms.jsp.CmsJspActionElement cms = new
org.opencms.jsp.CmsJspActionElement(pageContext, request, response);
// Write out the neccessary JavaScript
out.println("<link rel=\"StyleSheet\" href=\"" +
cms.link("../resources/css/dtree.css") +"\" type=\"text/css\" />");
out.println("<script type=\"text/javascript\" src=\"" +
cms.link("../resources/javascript/dtree.js") + "\"></script>");
out.println("<script type=\"text/javascript\">");
out.println("<!--");
out.println("navtree = new dTree('navtree');");
out.println("navtree.add(0,-1,'bonprix Intranet','/','','','');");
// Get a simple navigation of all pages / subfolders in the current
folder
List list = cms.getNavigation().getSiteNavigation(rootFolder,99);
Iterator i = list.iterator();
// the node directory contains the numbers of each node
Hashtable nodeDirectory = new Hashtable();
// The next available node number is in the nodeCounter
int nodeCounter = 1;
// Self explaining
int parentNode = -1;
int currentNode = 1;
while (i.hasNext()) {
org.opencms.jsp.CmsJspNavElement ne =
(org.opencms.jsp.CmsJspNavElement)i.next();
if (ne.getParentFolderName().equals(rootFolder)) {
parentNode = 0;
} else {
parentNode =
((Integer)(nodeDirectory.get(ne.getParentFolderName()))).intValue();
};
nodeDirectory.put(ne.getResourceName(),new Integer(nodeCounter));
currentNode = nodeCounter;
nodeCounter++;
// d.add(12,0,'Recycle Bin','default.html','','','');
out.println("navtree.add(" + currentNode +"," + parentNode + ", '" +
ne.getNavText() + "', '" + cms.link(ne.getResourceName()) + "', '" + (
ne.getDescription() != null ? ne.getDescription() :"") + "');");
}
out.println("document.write(navtree);");
out.println("//-->");
out.println("</script>");
%>
</div>
(Feel free to use it if you can get it working)!
More information about the opencms-dev
mailing list