[opencms-dev] modifing properties of resources returned by contentload

Roman Uhlig roman.uhlig at knve.de
Mon Aug 7 18:49:24 CEST 2006


Hi Eric!

Yes, this is possible by using CmsJspXmlContentBean.contentload, introduced
with Opencms 6.2.

This way we implemented a comfortable way of sorting XMLcontent by priority
for our editors:
http://www.idaba.de/tmp/opencms_prioritysort.jpg

Here's a code snippet for illustrating the important parts. It's setting a
new priority for a set of XMLcontent objects and it's siblings (i.e.
multilanguage site):

// initializing the XmlContentBean
CmsJspXmlContentBean jcb = new CmsJspXmlContentBean(pageContext, request,
response);

// setting the collector type and initializing a ContentContainer
String collectorName = new String("allInFolderPriorityDateDesc");
I_CmsXmlContentContainer a_contentContainer = jcb.contentload(collectorName,
collectorParameter, new java.util.Locale(arr_used_languages[lang_count]),
false);

// getting the collector results
List contentList = a_contentContainer.getCollectorResult();

// iterating the results and getting/setting properties
while(a_contentContainer.hasMoreContent()){
   CmsObject cmsObj = jcb.getCmsObject(); 
   cmsObj.lockResource(a_contentContainer.getResourceName());	

   Map properties =
cmsObj.readProperties(a_contentContainer.getResourceName());

   // setting a new priority
   properties.put(new String("collector.priority"), String.valueOf(20));

   cmsObj.writeProperties(a_contentContainer.getResourceName(), properties);
   cmsObj.unlockResource(a_contentContainer.getResourceName());
}


I hope this helps a bit.

Best regards,
Roman
-- 
View this message in context: http://www.nabble.com/modifing-properties-of-resources-returned-by-contentload-tf2040136.html#a5688675
Sent from the OpenCMS - Dev forum at Nabble.com.




More information about the opencms-dev mailing list