[opencms-dev] Cook book =) How to list files.

Wils wilson.neto at cesar.org.br
Tue Jan 24 13:41:33 CET 2006


Dear friends,

Recently i needed list the archives of a directory and had some problems.
I needed this to list articles from my site, but, when twirled the script it display nothing, 
the problem was in the "NavPos" and "NavText". Now, it work fine =)

1 - Create your files and put, in the properties button set the "NavPos" and "NavText"
2 - Copy this sample:

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

// Author: wilson.neto at pitang.com

// Create a JSP action element
org.opencms.jsp.CmsJspActionElement cms = new org.opencms.jsp.CmsJspActionElement(pageContext, request, response);

// Get a simple navigation of all pages / subfolders in the current folder
List list  = cms.getNavigation().getNavigationForFolder("/sites/default/");  // << Please, put hre your directory
Iterator i  = list.iterator();

//out.println("<h3>Artigos disponiveis:</h3> " + list.size()  );

while (i.hasNext()) 
{
    org.opencms.jsp.CmsJspNavElement ne = (org.opencms.jsp.CmsJspNavElement)i.next();

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

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

%>

Tks to all
Wils
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://webmail.opencms.org/pipermail/opencms-dev/attachments/20060124/b41cb274/attachment.htm>


More information about the opencms-dev mailing list