Posts: 524
Threads: 48
Joined: Mar 2011
How do I get a page's last modification date analogous to a page's creation date?
I saw that last mod date is used in the backend, but I was unable to find the function. Sight's getting kind of blurry at this time of the night. Maybe someone can help me out?
Posts: 661
Threads: 52
Joined: Feb 2011
2011-04-24, 11:02:26
(This post was last modified: 2011-04-24, 11:06:48 by OOuineur.)
You could always use the php filemtime() function:
Code:
$filename = "somepage.xml";
filemtime($filename));
http://php.net/manual/en/function.filemtime.php
Or there is the 'pubDate' node in each xml file which tells the last modified date and time
Posts: 2,094
Threads: 54
Joined: Jan 2011
polyfragmented Wrote:How do I get a page's last modification date analogous to a page's creation date?
I saw that last mod date is used in the backend, but I was unable to find the function. Sight's getting kind of blurry at this time of the night. Maybe someone can help me out?
On the front end to get the current page's last modification date:
get_page_date(...)
With the I18N Customfields plugin to get the creation date:
get_page_creation_date(...)
In the xml page files as strings:
pubDate and
creDate
Convert them to Unix time stamps: strtotime(...)
Format a Unix time stamp locale specific:
setLocale(...); strftime(...)
Posts: 47
Threads: 7
Joined: Dec 2016
(2011-04-24, 11:02:26)mikeh Wrote: You could always use the php filemtime() function
I'd like to ask about using the
filemtime() function in GetSimple CMS.
I test my web on localhost (on Linux) for now and want to know the last modification time of a page that has the slug "important". After some attempts, I have discovered that only the absolute filesystem's path to the file in question works ("
filemtime("/var/www/html/tmt/data/pages/important.xml") "). But this naturally will stop working after moving the web to a webserver. I tried to write a relative path to the file (in relation to what starting point? - the script is in the file
theme/Innovation/template.php) or an absolute path using "http://localhost/" but I haven't succeed. So what path should I set in a production webserver?
Posts: 538
Threads: 12
Joined: May 2013
first of, you should detect the 'full path' of your xml file. You can do it with pwd command on ssh console from directory where the file is located.
Or you can do it with php from your template.php file:
Code:
<?php echo __DIR__; ?>
you get something like this:
/var/bla-bla/foo/theme/Innovation
so you can extend it with the relative path to your xml file:
/var/bla-bla/foo/data/pages/important.xml
Posts: 538
Threads: 12
Joined: May 2013
PS. if it's the GS pages directory, maybe better to do it with the GS constant GSDATAPAGESPATH
Code:
filemtime(GSDATAPAGESPATH.important.xml)
Posts: 47
Threads: 7
Joined: Dec 2016
Thank you very much.
The second one correctly should be
Code:
filemtime(GSDATAPAGESPATH."important.xml")
Information about the GSDATAPAGESPATH constant should maybe be added in the wiki.