[opencms-dev] how to get CmsResource object for current page?

Joe Desbonnet jdesbonnet at gmail.com
Mon Jul 18 22:27:56 CEST 2005


Thomas,

Thanks -- the bit I was missing was the .getUri() method of
CmsRequestContext to use
with the readResource() method of CmsObject

So I can now add the last modified date to the template with this line:

Page last modified: <%=
java.util.Date( cms.getCmsObject().readResource(
cms.getCmsObject().getRequestContext().getUri()
).getDateLastModified()
) %>

However the API does seem a little contorted to me. I'm calling
getCmsObject() twice. Is there a cleaner way to do this? A
getCmsResource() method on the CmsObject would be nice.

Thanks,
Joe.



On 7/18/05, Thomas Maerz <thomasmaerz at gmx.de> wrote:
> Joe Desbonnet <jdesbonnet at gmail.com> writes:
> 
> > I can get a CmsObject and a CmsRequestContext for the current page,
> > but I cannot see any easy way to convert that into an instance of
> > CmsResource.
> 
> 
> ,----[ CmsObject ]
> | public CmsResource readResource(String resourcename) throws CmsException {
> |
> |     return readResource(resourcename, CmsResourceFilter.DEFAULT);
> | }
> `----
> 
> 
> Regards,
> Thomas
> 
> 
> 
> _______________________________________________
> This mail is send to you from the opencms-dev mailing list
> To change your list options, or to unsubscribe from the list, please visit
> http://mail.opencms.org/mailman/listinfo/opencms-dev
>



More information about the opencms-dev mailing list