In my Page templates, I want to print the last publish date.
Where can I find the last publish date ?
thanks
Manvinder
In my Page templates, I want to print the last publish date.
Where can I find the last publish date ?
thanks
Manvinder
So far based on my research, it appears there is no easy way that we can get the last publish date.
One way I was thinking to design/ implement is to write a JEXL extension for it. This extension would take the content id of the item as a parameter. It would then execute a query to the DB content status table, fetch the publish date/ time, format and return it.
The templates can invoke this JEXL expression and pass in the content id. The JEXL expr. would return the value, and the templates can print the last publish date.
Opinions on the above approach?
manvinder
The pub date is available in JEXL as $sys.item.getProperty(“sys_pubDate”). In fact, your suggestion about reading the content status table will return exactly the same thing that this call will.
The pub date should be updated every time the item is published, so it’s always the last time this item was re-published.
Minor point, but I believe that it is $sys.item.getProperty(“sys_pubdate”).Date…The D in sys_pubdate should not be capitalized…
Yes, “sys_pubdate” is correct.
Thanks Dave and Jitendra.
In my templates, I invoked as follows:
Last Publish Date:$sys.item.getProperty(“sys_pubdate”)
However, when during the preview of my content item, I notice following message:
Last Publish Date:com.percussion.utils.jsr170.PSProperty@d85d61[name=rx:sys_pubdate,value=,initialized=false]
thanks
Manvinder
Have you ever published the item? If not, then you’ll need a “IF” statement to make sure that the value is initialized.
Also, you will probably want to format the output of the date, using $tools.date.format() or at the very least convert it to a String (using something like
$sys.item.getProperty(“sys_pubdate”).String
I am sorry, again a few very naive questions:
pubdate seems to only return the date…anything that returns both date and time?
Also $tools.date.format() appears to take 4 parameters, and I was not able to find documentation on those four parameters. Not sure what should I pass into this method to make the publish date/ time to print out formatted.
thanks
manvinder
after reading the java docs, do something like:
$tools.date.format("yyyy-MM-dd",$sys.item.getProperty("sys_pubdate").Date)
where yyyy-MM-dd would be how you want to format the date…note that the time is also provided, just use what is specified in the java doc to get the time…
Just for completeness, the JavaDoc for the Velocity Date tool is here:
http://velocity.apache.org/tools/devel/javadoc/org/apache/velocity/tools/generic/DateTool.html
There are several “shortcuts” to different date formats, although the example given by Jit will certainly work.
Dave
I am playing with the home page in Enterprise Investments. I made changes several time to the content item, and ran the Edition couple of times. However, whenever I print the last date/ time it is saying the following value:
Last Publish Date:2008-02-09 0:0:0
As Jitendra mentioned, this is the code I am using in my template:
Last Publish Date:$tools.date.format(“yyyy-MM-dd H:m:s”,$sys.item.getProperty(“sys_pubdate”).Date)
thanks
Manvinder