Forum

Thread tagged as: Question, Problem, Suggestions

Get the time a content item was created and updated

Is it possible to get the time a content item was last created and updated? I've looked at what's kept in Perch's database and what comes out when using perch_custom_content(), but I can't seem to find this information anywhere.

The reason I ask is because I'm automatically generating PDFs of webpages that are built using Perch, but I only want to generate the files if the record was updated after the most recent file was generated.

Some way to hook into Perch at certain events (before/after saving) would be the ideal solution, but this doesn't appear to be possible.

James Harrison

James Harrison 0 points

  • 7 years ago
Drew McLellan

Drew McLellan 2638 points
Perch Support

You can get the time the page was modified as a whole. Does that help?

https://docs.grabaperch.com/docs/navigation/perch-page-modified/

It doesn't look like this will work for what I'm doing as there's no way to specify — at least from what I can see — the page you want the modified timestamp of.

Drew McLellan

Drew McLellan 2638 points
Perch Support

It's the current page, so you could switch pages using PerchSystem::set_page()

https://docs.grabaperch.com/docs/developers/working-with-front-controllers/

Ahh, I'd totally forgotten about that, thanks. I don't think this will work for my purposes though, as I need to know specifically when an individual content item was last changed, not the page as whole.

I think I'll have to make my own Perch field type to capture this information instead.