SOLVED - Get true modified date

Using the modified function on a Kirby page gives the modified date of the folder which is only changed when files are added or removed.

I’m trying to figure out a non-convoluted way to get the modification date of the actual content file, as that will give me a more accurate date of when the content was actually updated on a page.

My first thought is to just use a PHP function to get the modified date on the content file, but I’m not finding any Kirby 2 function that lets me get the full path to the actual content file. Does such a thing exist? Any other ideas?

To get the path, maybe you can combine

$page->diruri() http://getkirby.com/docs/cheatsheet/page/diruri
$page->dirname() http://getkirby.com/docs/cheatsheet/page/dirname
$page->intendedTemplate() http://getkirby.com/docs/cheatsheet/page/intended-template

  • .txt
2 Likes

Hmm…seems a little clunky, but intended-template is the closest I’ve come yet. I thought about using the template name, but that doesn’t always equal the name of the content file. This might do the trick. Thanks!

There is $page->textfile() that might do the trick.

3 Likes

That’s perfect, actually. Not sure why I didn’t find that before. Thanks!

$page->textfile() includes the full root path, too, so I don’t have to add $page->root().

Ha, didn’t know that one! Is it missing on the Cheatsheet, @bastianallgeier? Can’t find it somehow.

I thought that behavior was odd from looking at the source code and briefly tested it by modifying a file and $page->modified() returned the last modified date like it should?

In my testing, $page->modified() didn’t change when I edited the content file. It only changed if I added or removed a file.