[opencms-dev] injecting Publish Date/Timestamp into page

] Code Create [ ocms at code-create.de
Thu Aug 7 12:43:30 CEST 2014


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
> |
> 
> 
> 
> 
> _______________________________________________
> 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
> 
> 
> 



More information about the opencms-dev mailing list