[opencms-dev] method to get exact categories of a resource

Giedrius Tumelis giedriustum at gmail.com
Wed Nov 7 11:27:27 CET 2012


Hi,

I am using readRelations method:


Collection<CmsRelation> relations =
cms.getRelationsForResource(resource, CmsRelationFilter.ALL);
			for (CmsRelation relation : relations) {
				CmsResource relResource = null;
				if (relation.getSourcePath().equals(resource.getRootPath())) {
					relResource = relation.getTarget(cms, CmsResourceFilter.ALL);
				} else {
					relResource = relation.getSource(cms, CmsResourceFilter.ALL);
				}
				if (relResource != null) {
						result.add(relResource);
				}
			}
			result.add(resource);


Later I filter needed categories by the starting path.
May be this is not the easiest way, but it works.

Regards,
Giedrius T.

2012/11/7 kaybe <kris.brys at redtree.be>:
>
> Is there a method I could use that gives me the 'exact categories' (By exact
> categories I mean as catagory_exact  in SOLR search). For example: an
> article has a category color/red AND local\Europe. When I use method
> readResourceCategories(CmsObject cms, CmsResource resource)  of
> CmsCategoryService I got 4 seperate categories listed: color, red, local,
> Europe. That way I can not display this in the formatter as "categories:
> color\red local\Europe."
> Kind regards,
> Kris
> --
> View this message in context: http://old.nabble.com/method-to-get-exact-categories-of-a-resource-tp34650986p34650986.html
> Sent from the OpenCMS - Dev mailing list archive at Nabble.com.
>
> _______________________________________________
> This mail is sent to you from the opencms-dev mailing list
> To change your list options, or to unsubscribe from the list, please visit
> http://lists.opencms.org/cgi-bin/mailman/listinfo/opencms-dev
>
>
>



More information about the opencms-dev mailing list