«

»

ago
30
2010

Recorrido del árbol VFS en OpenCms

Si se quiere consultar cualquier tipo de contenido estructurado del VFS no tenemos más que usar el collector allInSubTree, pero si necesitamos un listado de carpetas, imágenes, pdfs, … no podemos hacerlo de esta manera.

Y esta era mi intención, un proceso que tratara de una manera especial todas las imágenes del sitio.

Aquí dejo el código para recorrer el árbol.

< %!
String recursivo(String path,org.opencms.file.CmsObject cmsObj){
	String dev ="<ul>";
try{
java.util.List lista = cmsObj.getResourcesInFolder(path,org.opencms.file.CmsResourceFilter.ALL);
java.util.Iterator it = lista.iterator();
		while(it.hasNext())
			{
org.opencms.file.CmsResource res = (org.opencms.file.CmsResource) it.next();
dev += "<li>" + res.getName()+"</li>";
			if (res.isFolder())
				{
dev+=recursivo(path+res.getName()+"/",cmsObj);
				}
			}
		}
catch (Exception e){
		}
return dev+"";
    	}
%>
<html>
<body>
< %
org.opencms.jsp.CmsJspActionElement cms = new org.opencms.jsp.CmsJspActionElement( pageContext, request, response );
org.opencms.file.CmsObject cmsObj = cms.getCmsObject();
out.println(recursivo("/",cmsObj));
%>
</body>
</html>

Enlace permanente a este artículo: http://blog.jromay.es/2010/08/30/recorrido-del-arbol-vfs-en-opencms/

Deja un comentario

Tu email nunca se publicará.

Puedes utilizar las siguientes etiquetas y atributos HTML: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>