[opencms-dev] how to access title all pages in a folder

Pavel Peringer pavel.peringer at qbizm.cz
Tue Aug 29 09:39:46 CEST 2006


Hello

Code snipet for OpenCms 6.2.X

1) use resource list

CmsJspActionElement cmsJsp = new CmsJspActionElement(pageContext, 
request, response);
CmsObject = cmsJsp.getCmsObject();
List resources = cmcObject.|getResourcesInFolder 
<../../../org/opencms/file/CmsObject.html#getResourcesInFolder%28java.lang.String,%20org.opencms.file.CmsResourceFilter%29>("|*/sites/default/modulesdemo/modules/faq/"*|, 
CmsResourceFilter 
<../../../org/opencms/file/CmsResourceFilter.html>.DEFAULT);
Iterator it = resources.iterator();
while (it.hasNext())
{
CmsResource resource = (CmsResource) it.next();
String title = cmsObject.readPropertyObject(resource, 
|CmsPropertyDefinition.|PROPERTY_TITLE 
<../../../org/opencms/file/CmsPropertyDefinition.html#PROPERTY_TITLE>, 
false||);

[show code here]
}

2) use navigation list (requested resources must be in navigation)

|CmsJspActionElement cmsJsp = new CmsJspActionElement(pageContext, 
request, response);
CmsNavBuilder cmsNavigation = cmsJsp.getNavigation();
||List resources = cmsNavigation.|getNavigationForFolder 
<../../../org/opencms/jsp/CmsJspNavBuilder.html#getNavigationForFolder%28java.lang.String%29>("|*/sites/default/modulesdemo/modules/faq/*|");||
Iterator it = resources.iterator();
while (it.hasNext())
{
||*CmsJspNavElement 
<../../../org/opencms/jsp/CmsJspNavElement.html#CmsJspNavElement%28%29>*|| 
element = (||*CmsJspNavElement 
<../../../org/opencms/jsp/CmsJspNavElement.html#CmsJspNavElement%28%29>*||) 
it.next();
String title = element.getTitle();||

[show code here]
}
|
I prefer the second method because you can set position (NavPos 
property) of every resource and make custom order.

HTH

Pavel Peringer

> Hi All,
>
> I want to render the title of all pages existing in folder 
> *“/sites/default/modulesdemo/modules/faq/” . *If I use 
> *getResourcesInFolder(String) *of *CmsObject* to access list of 
> resources , I don’t get “title” of resource from Object of resource .
>
> Can somebody plz tell me how to access the title of all pages existing 
> in folder *“/sites/default/modulesdemo/modules/faq/”.*
>
> Regards:
>
> Sarthak Mishra
>
>------------------------------------------------------------------------
>
>
>_______________________________________________
>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/mailman/listinfo/opencms-dev
>


-- 
Pavel Peringer                              Qbizm technologies, a.s.
programator                                 ... the art of software.
____________________________________________________________________
www.qbizm-technologies.cz    www.qbizm.cz      www.qbizm-services.cz




More information about the opencms-dev mailing list