Jump to content

Get the last time a change was made


Sinmok
 Share

Recommended Posts

Hello all,

I was wondering what the most elegant solution would be to find out when the last time a change was made to any regular pages (not admin pages)?

Cheers.

Update: 

Sigh was trying to overcomplicate things again. The easiest solution is:

$page = wire("pages")->find("sort=-modified")->first()->modified;
  • Like 1
Link to comment
Share on other sites

This should give you some understanding:

$selArray = array(
    "id!=$config->adminRootPageID|$config->trashPageID|$config->http404PageID", // ID as in /wire/config.php
    "template!=admin",
    "has_parent!=$config->adminRootPageID", // excludes "admin" branch all children recursively
    "include=all", // all pages regardless of access and status
    "sort=-modified",
    );

$list = "";

foreach($pages->find(implode(",",$selArray)) as $p) {

    $date = date("Y.m.d H:i:s", $p->modified);
    $list .= "<li><a href='{$config->urls->admin}page/edit/?id=$p->id'>$date - $p->path</a></li>";

}

echo "<ul>$list</ul>";
Link to comment
Share on other sites

So with the selector of above you could get the lastest modified date with 

$selArray = array(
    "id!=$config->adminRootPageID|$config->trashPageID|$config->http404PageID",
    "template!=admin",
    "has_parent!=$config->adminRootPageID",
    "include=all",
    "sort=-modified"
    );

$lastDateModified = date("Y.m.d H:i:s", $pages->get(implode(",",$selArray))->modified);
// or
$lastDateModified = date("Y.m.d H:i:s", $pages->findOne(implode(",",$selArray))->modified);
Link to comment
Share on other sites

"id!=$config->adminRootPageID|$config->trashPageID|$config->http404PageID",

That part above probably isn't necessary in the selector. The "template!=admin" and "has_parent!=$config->adminRootPageID" will probably cover everything you need (assuming you want admin pages excluded from last modified listings). While you could exclude the 404 page, I'm guessing that's one that probably rarely if ever ends up in a modified list anyway. 

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...