[opencms-dev] directory listing

Isaac R. Higgins isaac.higgins at isaacray.com
Thu Apr 3 18:46:16 CEST 2008


set your path on line 12:


<%@ page session="false" %>
<%@ taglib prefix="cms" uri="http://www.opencms.org/taglib/cms" %>

<jsp:useBean id="cmsbean" class="org.opencms.jsp.CmsJspBean">
  <% cmsbean.init(pageContext, request, response); %>
</jsp:useBean>

<%
  org.opencms.file.CmsObject cms = cmsbean.getCmsObject();
  org.opencms.file.CmsResourceFilter filter = org.opencms.file.CmsResourceFilter.DEFAULT;
  filter = filter.addExcludeType(new org.opencms.file.types.CmsResourceTypeJsp().getStaticTypeId() );
  java.util.List al = cms.getResourcesInFolder("/construction_docs/Kiser/", filter);
%>

<cms:include property="template" element="head" />
<br />
<h2>The following are files in this folder:</h2>
  <blockquote>
<%
 for (int i=0;i<al.size();++i){
	org.opencms.file.CmsResource ress = null;
	String description = "";
	try{
		ress = cms.readResource(cms.getSitePath((org.opencms.file.CmsResource)al.get(i)));
		description = cms.readPropertyObject(ress,"Title",false).getValue();
	}catch(Exception e){out.print(e);}
%>
 <%= i+1%>. <a href="<%= (new org.opencms.jsp.CmsJspActionElement(pageContext, request, response)).link(cms.getSitePath((org.opencms.file.CmsResource)al.get(i))) %>"><%=description%></a>
 <br>
<%}%>
  </blockquote>

<cms:include property="template" element="foot" />

-----Original Message-----
From: opencms-dev-bounces at opencms.org on behalf of Wagner,Aaron
Sent: Thu 4/3/2008 11:04 AM
To: The OpenCms mailing list
Subject: [opencms-dev] directory listing
 
 

I have a directory listing script like this, but now I need to expand it
to show all kinds of files, IE binary(pdf, doc, etc).  It appears that
the getNavigationForFolder(); only shows xmlpage file types.

 

I don't have access to change the directory listing settings in web.xml
of the Tomcat server.  Does anyone have any ideas to show all files in a
directory?

 

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

<%@ page import="java.util.*,

                 org.opencms.jsp.*" %><%     

 

// Create a JSP action element

CmsJspActionElement cms = new CmsJspActionElement(pageContext, request,
response);

 

// Get a simple navigation of all pages / subfolders in the current
folder 

String uri = cms.getRequestContext().getUri();

String uri2 = uri.substring(0, uri.lastIndexOf("/"));

 

List list = cms.getNavigation().getNavigationForFolder();

Iterator i = list.iterator();

int navnumb = list.size();

 

out.println("<h3>Directory listing for " + uri2 + " | Number of files: "
+ navnumb +"</h3><ul>");

while (i.hasNext()) {

  CmsJspNavElement ne = (CmsJspNavElement)i.next();

  out.println("<li><a href=\"" + cms.link(ne.getFileName()) + "\">");

  out.println(ne.getTitle() + "</a></li>");

}    

out.println("</ul>");

%>

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

 

Opencms 6,2,3

Tomcat 5

Ocacle 10

 

 

Aaron N Wagner

Web Developer, Office of Public Affairs

DEQ - Virginia Department of Environmental Quality

[W] 804.698.4265

 

There are 10 types of people in the world: those who understand binary,
and those who don't. 

 


-------------- next part --------------
A non-text attachment was scrubbed...
Name: winmail.dat
Type: application/ms-tnef
Size: 4176 bytes
Desc: not available
URL: <https://webmail.opencms.org/pipermail/opencms-dev/attachments/20080403/f7dc150d/attachment.bin>


More information about the opencms-dev mailing list