[opencms-dev] Methods for "getFilename" and "lastmodified" ???

Olli Aro olli_aro at yahoo.co.uk
Wed May 28 10:39:01 CEST 2003


Hi Birgit,

You have to create your own template class by extending the class
com.opencms.template.CmsXmlTemplate and then create a method like below.

public String getLastModifiedDate(CmsObject cms, String tagcontent,
A_CmsXmlContent doc, Object userObject)
	throws CmsException
	{
		String lastModified="";

		//Get requested resource.
		CmsResource res=cms.readFile(cms.getRequestContext().getUri());

		//Get the last modified date.
		if(res!=null)
		{
			Date date=new Date(res.getDateLastModified());
			Calendar cal=Calendar.getInstance();
			cal.setTime(date);

              //Format the date string.

lastModified=cal.get(Calendar.DAY_OF_MONTH)+"."+(cal.get(Calendar.MONTH)+1)+
"."+cal.get(Calendar.YEAR);
		}

		return lastModified;
	}

Then use your new template class instead com.opencms.template.CmsXmlTemplate
and call the method your template by <method name="getLastModifiedDate"/>.

Hopefully this helps,

Olli


> -----Original Message-----
> From: opencms-dev-admin at opencms.org
> [mailto:opencms-dev-admin at opencms.org]On Behalf Of Birgit Hämmerling
> Sent: 28 May 2003 08:22
> To: opencms-dev at opencms.org
> Subject: RE: [opencms-dev] Methods for "getFilename" and "lastmodified"
> ???
>
>
> Hi Oli !!
>
> Your answer shows the right direction... but doesn't fit to my problem...
>
> I'd like to get the (last) publication date, date of last
> modification e.g.
> of a html file that uses templates of the class
> com.opencms.CmsXmlTemplate. I
> looked at the source code of that java class but I didn't find a suitable
> method for my problem.
>
> To get the title of this html-file I can use the following method:
> <method name="getTitle"/>
>
> What is the right method to insert the date ??
> (Could you please give me an example - to avoid misunderstandings ??)
>
> Greetings,
> Birgit
>
>
> > Last modified date can be fetched with
> CmsResource.getDateLastModified().
> >
> > Regards,
> >
> > Olli
> >
>
> --
> +++ GMX - Mail, Messaging & more  http://www.gmx.net +++
> Bitte lächeln! Fotogalerie online mit GMX ohne eigene Homepage!
>
> _______________________________________________
> 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
> ---
> Incoming mail is certified Virus Free.
> Checked by AVG anti-virus system (http://www.grisoft.com).
> Version: 6.0.483 / Virus Database: 279 - Release Date: 19/05/2003
>
---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.483 / Virus Database: 279 - Release Date: 19/05/2003





More information about the opencms-dev mailing list