[opencms-dev] injecting Publish Date/Timestamp into page
Schliemann, Kai
K.Schliemann at comundus.com
Thu Aug 7 16:00:18 CEST 2014
Hi Chris,
you can find a lot of help in the pdf ship with OpenCms since version 8.
Find attached a screenshot with some useful resource related functions.
HTH
BR
Kai
-----Ursprüngliche Nachricht-----
Von: opencms-dev-bounces at opencms.org [mailto:opencms-dev-bounces at opencms.org] Im Auftrag von Christoph Kukulies
Gesendet: Donnerstag, 7. August 2014 12:57
An: ocms at code-create.de; The OpenCms mailing list
Betreff: Re: [opencms-dev] injecting Publish Date/Timestamp into page
Hi Bernd,
nice idea. Do you happen to know which element to access to obtain the GetDateLastModified().
It looks like it's in CmsCntPageData.
Am 07.08.2014 12:43, schrieb ] Code Create [:
> Hi Chris,
>
> why don't you simply use "getDateLastModified".
> Because, if it is not published it doesn't matter.
> If it is published the date last modified should be fine if there is not
> a too great time span in between. If there is you could just refresh the
> resource prior to publishing it.
>
> Me, I use an extra schema field/property to set a real publication date
> (date issued).
> Because I don't want to have this "issued date" changed, just because I
> republish a resource for technical reasons, like orthography errors, or
> if you have to republish the whole site for some other reason ... all
> publish dates would be the same ...; i assume, that's not what you want.
>
> For the same reason I have an extra field/property for the last edit
> date too :D
>
> All the best, Bernd
>
> Am 07.08.2014 11:58, schrieb Christoph Kukulies:
>> I'm seeking for a means to insert the date/time a page was published
>> last time so that one can read e.g. at the bottom of a
>> page something like "last edit Aug, 7th, 2014".
>>
>> I found some suggestion in a stackoverflow thread
>> <http://stackoverflow.com/questions/14338306/how-to-get-last-published-date-from-a-cmsresource-in-opencms>:
>>
>> |public static Date getLastPublishedDate(CmsJspActionElement cms, CmsResource resource) throws Exception {
>> CmsObject cmso = cms.getCmsObject();
>> String sitePath = cmso.getSitePath(resource);
>>
>> if (cmso.readAllAvailableVersions(sitePath).size() > 0) {
>> I_CmsHistoryResource histRes = cmso.readAllAvailableVersions(sitePath).get(0);
>> int publishTag = histRes.getPublishTag();
>> CmsHistoryProject project = cmso.readHistoryProject(publishTag);
>> return new Date(project.getPublishingDate());
>> } else {
>> return null;
>> }
>> }
>>
>> I'm wondering whether it could be accomplished in another way.
>>
>> --
>> Chris Christoph P. U. Kukulies kukulies (at) rwth-aachen.de
>> |
>>
--
Chris Christoph P. U. Kukulies kukulies (at) rwth-aachen.de
_______________________________________________
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
-------------- next part --------------
A non-text attachment was scrubbed...
Name: OpenCms-9.0.1-Documentation_v2.1-8.2.6-the-resource-bean.gif
Type: image/gif
Size: 63990 bytes
Desc: OpenCms-9.0.1-Documentation_v2.1-8.2.6-the-resource-bean.gif
URL: <https://webmail.opencms.org/pipermail/opencms-dev/attachments/20140807/cf6bd646/attachment.gif>
More information about the opencms-dev
mailing list