[opencms-dev] get all categories listed
kaybe
kris.brys at redtree.be
Mon Oct 15 15:14:15 CEST 2012
I'm trying to list all categories and iterate over them, using
CmsCategoryService with method readCategories. But I get no results, no
exception either, just an empty list. I made a category folder 'theme' in
'/sites/default/_catagories/' and made some categories under this 'theme'
category.
Is this the wrong method?
I tried different paths like "_categories", "_categories/", etc...
<%@page buffer="none" session="false" import="java.util.*,
org.opencms.file.*, org.opencms.jsp.*, org.opencms.util.*,
org.opencms.relations.CmsCategoryService" %>
<%@ taglib prefix="cms" uri="http://www.opencms.org/taglib/cms" %>
<%!
public void buildCategoryMap(CmsJspActionElement cms, String uri,
java.io.Writer out) throws Exception
{
final String REFERENCE_PATH = "/sites/default/_categories/";
final String CATEGORY_NAME = "theme";
final boolean INCLUDE_SUB_CATEGORIES = false;
int amount = 0;
CmsObject cmso = cms.getCmsObject();
CmsCategoryService catService = CmsCategoryService.getInstance(); // Get
the singleton
try {
List res = catService.readCategories(cmso, REFERENCE_PATH, false,
CATEGORY_NAME);
Iterator i = res.iterator();
while (i.hasNext()) {
amount++;
out.write("<li>" + amount + "</li>");
}
}
catch (Exception e) {
out.write("<li>something is very wrong</li>");
}
}
--
View this message in context: http://old.nabble.com/get-all-categories-listed-tp34558113p34558113.html
Sent from the OpenCMS - Dev mailing list archive at Nabble.com.
More information about the opencms-dev
mailing list