Source code for: /system/modules/com.alkacon.documentation/elements/navigation.jsp
<%@ page session="false" import="org.opencms.jsp.*" %><%--
This program is part of the Alkacon OpenCms Software library.
This license applies to all programs, pages, Java classes, parts and
modules of the Alkacon OpenCms Software library published by
Alkacon Software GmbH, unless otherwise noted.
Copyright (c) 2005 Alkacon Software GmbH (http://www.alkacon.com)
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or (at
your option) any later version.
This program is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
For further information about Alkacon Software GmbH, please see the
companys website: http://www.alkacon.com.
For further information about OpenCms, please see the OpenCms project
website: http://www.opencms.org.
The names "Alkacon", "Alkacon Software GmbH" and "OpenCms" must not be used
to endorse or promote products derived from this software without prior
written permission. For written permission, please contact info@alkacon.com.
Products derived from this software may not be called "Alkacon",
"Alkacon Software GmbH" or "OpenCms", nor may "Alkacon", "Alkacon Software GmbH"
or "OpenCms" appear in their name, without prior written permission of
Alkacon Software GmbH.
This program is also available under a commercial non-GPL license. For
pricing and ordering information, please inquire at sales@alkacon.com.
--%><%
try {
/*
* 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
org.opencms.jsp.CmsJspActionElement cms = new CmsJspActionElement(pageContext, request, response);
// Get the current folder name
String filename, foldername, filenameparam;
filename = cms.getRequestContext().getUri();
if ((filenameparam = request.getParameter("filename")) == null) {
foldername = org.opencms.file.CmsResource.getFolderPath(filename);
} else {
foldername = org.opencms.file.CmsResource.getFolderPath(filenameparam);
String foldernameprop = cms.property("target", filename);
if (foldernameprop != null) foldername = foldernameprop + foldername;
}
String rootFolder = "/alkacon-documentation/";
String moduleFolder = "/system/modules/com.alkacon.documentation/";
String showsource = cms.property("showsource", filename, "no");
String targetframe = request.getParameter("targetframe");
if (targetframe == null || "".equals(targetframe) || "null".equals(targetframe)) {
targetframe = "_self";
}
// Start to build the navigation
CmsJspNavElement element = null;
// 1: Backlink to overview
if (! foldername.equals(rootFolder)) {
element = cms.getNavigation().getNavigationForResource(rootFolder);
if (element.isInNavigation()) {
out.println("<p class=\"navtop\"><a class=\"nav\" target=\"_top\" href=\"" +
cms.link(rootFolder + "index.html") +
"\">[" + element.getNavText() + "]</a></p>");
}
}
// 2: Headline for current folder navigation
element = cms.getNavigation().getNavigationForResource(foldername);
if (element.isInNavigation()) {
out.println("<p class=\"nav\"><b>" + element.getNavText() + "</b></p>");
}
// 3: List of all pages / subfolders (sorted by NavPos property)
java.util.List list = cms.getNavigation().getNavigationForFolder(foldername);
java.util.Iterator i = list.iterator();
while (i.hasNext()) {
CmsJspNavElement ne = (CmsJspNavElement)i.next();
if (!ne.getNavText().startsWith("??? ")) {
if (! ne.isFolderLink()) {
if (! ne.getResourceName().equals(filename)) {
out.println("<p class=\"nav\"><a class=\"nav\" href=\"" +
cms.link(ne.getResourceName()) +
"\" target=\"" + targetframe + "\">" + ne.getNavText() + "</a></p>");
} else {
out.println("<p class=\"nav\">* " +
ne.getNavText() + "</p>");
}
} else {
out.println("<p class=\"navfolder\"><a class=\"nav\" href=\"" +
cms.link(ne.getResourceName() ) +
"\">> " + ne.getNavText() + "</a></p>");
}
}
}
if ("yes".equals(showsource)) {
// 4: "Show Source" link
out.println("<p class=\"navsource\"><a class=\"nav\" href=\"" +
cms.link(rootFolder + "showsource.jsp") +
"?filename=" + filename + "\">" +
"[Source of this page]" +
"</a></p>");
}
} catch (Throwable t) {
}
%>
|