opencms取得全站一二级导航

RIA知识库
flex
RIA
取得当前位置导航和下一级导航
<%@ page import="java.util.*,org.opencms.jsp.*,org.opencms.file.CmsResource.*,org.opencms.frontend.templateone.*" %>   
<%   
// Create a JSP action element   
CmsJspActionElement cms = new CmsJspActionElement(pageContext, request, response);   
// Some shortcuts to often used Strings   
String filename = cms.getCmsObject().getRequestContext().getUri();   
String foldername=org.opencms.file.CmsResource.getFolderPath(filename);   
String foldericon=cms.link("system/modules/com.alkacon.documentation/resources/ic_folder.gif");   
String fileicon=cms.link("system/modules/com.alkacon.documentation/resources/ic_file.gif");   
  
// List of all pages / subfolders (sorted by NavPos property)   
List list = cms.getNavigation().getNavigationForFolder();   
Iterator i = list.iterator();   
// Now build the navigation   
out.println("<div id=\"dhtmlgoodies_slidedown_menu\"><ul>");   
while (i.hasNext()) {   
    CmsJspNavElement ne = (CmsJspNavElement)i.next();   
      
    String target=ne.getProperty("target");   
    if(target==null)   
        target="_self";   
    if (ne.getResourceName().equals(filename)) {   
       out.println("<b>");   
       out.println(ne.getNavText()+"</b>");   
    }    
    else {    
        out.println("<li><a href=\"" + cms.link(ne.getResourceName()) + "\"target=\""+"\">" + ne.getNavText() + "</a></li>");   
        if(ne.isFolderLink()){   
           List subnav = cms.getNavigation().getSiteNavigation(ne.getResourceName(),-1);   
           Iterator j = subnav.iterator();   
           out.println("<ul>");   
           while (j.hasNext()) {   
                CmsJspNavElement ne2 = (CmsJspNavElement)j.next();   
                if (!ne2.getResourceName().equals(filename)) {   
                   out.println("<li><a href=\"" + cms.link(ne2.getResourceName()) + "\"target=\""+"\">" + ne2.getNavText() + "</a></li>");    
                }   
                else {   
                      out.println("<b>");   
                      out.println(ne2.getNavText()+"</b>");   
                }   
            }   
         out.println("</ul>");   
         }    
    }    
}   
    out.println("</ul></div>");   
%>  


--------------------------------------------------------------------------------
取得全站一二级导航
<%@ page import="java.util.*,org.opencms.jsp.*,org.opencms.file.CmsResource.*,org.opencms.frontend.templateone.*" %>   
<%   
// Create a JSP action element   
CmsJspActionElement cms = new CmsJspActionElement(pageContext, request, response);   
// Some shortcuts to often used Strings   
String filename = cms.getCmsObject().getRequestContext().getUri();   
String foldername=org.opencms.file.CmsResource.getFolderPath(filename);   
String foldericon=cms.link("system/modules/com.alkacon.documentation/resources/ic_folder.gif");   
String fileicon=cms.link("system/modules/com.alkacon.documentation/resources/ic_file.gif");   
  
// List of all pages / subfolders (sorted by NavPos property)   
List list = cms.getNavigation().getNavigationForFolder("/");   
Iterator i = list.iterator();   
// Now build the navigation   
out.println("<div id=\"dhtmlgoodies_slidedown_menu\"><ul>");   
while (i.hasNext()) {   
    CmsJspNavElement ne = (CmsJspNavElement)i.next();   
      
    String target=ne.getProperty("target");   
    if(target==null)   
        target="_self";   
    if (ne.getResourceName().equals(filename)) {   
       out.println("<b>");   
       out.println(ne.getNavText()+"</b>");   
    }    
    else {    
        out.println("<li><a href=\"" + cms.link(ne.getResourceName()) + "\"target=\""+"\">" + ne.getNavText() + "</a></li>");   
        if(ne.isFolderLink()){   
           List subnav = cms.getNavigation().getSiteNavigation(ne.getResourceName(),-1);   
           Iterator j = subnav.iterator();   
           out.println("<ul>");   
           while (j.hasNext()) {   
                CmsJspNavElement ne2 = (CmsJspNavElement)j.next();   
                if (!ne2.getResourceName().equals(filename)) {   
                   out.println("<li><a href=\"" + cms.link(ne2.getResourceName()) + "\"target=\""+"\">" + ne2.getNavText() + "</a></li>");    
                }   
                else {   
                      out.println("<b>");   
                      out.println(ne2.getNavText()+"</b>");   
                }   
            }   
         out.println("</ul>");   
         }    
    }    
}   
    out.println("</ul></div>");   
%>  

---------------------------------------------------------------------------------------------

取得当前文件 title导航
<%@page session="false" import="org.opencms.frontend.templatetwo.*"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %>
<%@ taglib prefix="cms" uri="http://www.opencms.org/taglib/cms"%><% 

    // This element defines breadcrumb navigation.
    //
	// It uses the CmsTemplateMenu class to provide some auxiliary methods
	// in order to prevent the use of scriplet code in this jsp.
	// For details on the CmsTemplateMenu class, see the source code which can
	// be found at the followinf VFS location:
	// /system/modules/org.opencms.frontend.templatetwo/java_src/CmsTemplateMenu.java

	CmsTemplateMenu cms = new CmsTemplateMenu(pageContext, request, response);
	pageContext.setAttribute("cms", cms);
	pageContext.setAttribute("navList", cms.getNavigation().getNavigationBreadCrumb(1, true));
%>

<c:set var="first" value="true" />
<c:forEach items="${navList}" var="elem" >
	<c:if test="${!empty cms.navText[elem]}">
		<c:if test="${!first}">&nbsp;»&nbsp;</c:if>
		<a href="<cms:link>${elem.resourceName}</cms:link>">${cms.navText[elem]}</a>
		<c:set var="first" value="false" />
	</c:if>
</c:forEach>

<c:if test="${!cms.isDefault || first}">
	<c:set var="navText"><cms:property name="NavText" /></c:set>
	<c:if test="${empty navText}">
		<c:set var="navText"><cms:property name="Title" /></c:set>
	</c:if>
	<c:if test="${!empty navText}">
		<c:if test="${!first}">
			&nbsp;»&nbsp;
		</c:if>
		<c:out value="${navText}" />
	</c:if>
</c:if>

================================================================================
取得当前导航的二级导航列表
<%@page session="false" import="org.opencms.frontend.templatetwo.*"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="cms" uri="http://www.opencms.org/taglib/cms"%><%

	// This element defines the left navigation element.
	// It uses the CmsTemplateMenu class to provide some auxiliary methods
	// in order to prevent the use of scriplet code in this jsp.
	// For details on the CmsTemplateMenu class, see the source code which can
	// be found at the following VFS location:
	// /system/modules/org.opencms.frontend.templatetwo/java_src/CmsTemplateMenu.java

	CmsTemplateMenu cms = new CmsTemplateMenu(pageContext, request, response);
	cms.setElements(cms.getNavigation().getNavigationTreeForFolder(cms.getRequestContext().getUri(), 1, 3));
	pageContext.setAttribute("cms", cms);
%>

<div id="nav_left">
	<ul>
		<c:set var="oldLevel" value="" />
		<c:forEach items="${cms.elements}" var="elem">
			<c:set var="currentLevel" value="${elem.navTreeLevel}" />
			
			<c:choose>
				<c:when test="${empty oldLevel}"></c:when>
				<c:when test="${currentLevel > oldLevel}"><ul></c:when>
				<c:when test="${currentLevel == oldLevel}"></li></c:when>
				<c:when test="${oldLevel > currentLevel}">
					<c:forEach begin="${currentLevel+1}" end="${oldLevel}"></li></ul></c:forEach>
				</c:when>
			</c:choose>
			
			<li><a href="<cms:link>${elem.resourceName}</cms:link>" <c:if test="${cms.isCurrent[elem]}">class="current"</c:if>>${elem.navText}</a>
			
			<c:set var="oldLevel" value="${currentLevel}" />
		</c:forEach>
		
		<c:forEach begin="${cms.topLevel+1}" end="${oldLevel}"></li></ul></c:forEach>
	</ul>
</div>


你可能感兴趣的:(java,jsp,cms,J#,sun)