Last active
August 29, 2015 14:20
-
-
Save trk/a9d7e01ecfa6e40b65bc to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Get last modified page modified date from given $id, $parent_id, $templates_id or from all | |
* | |
* @param bool $id | |
* @param bool $parent_id | |
* @param bool $templates_id | |
* @return mixed|string | |
*/ | |
function getLastModified($id=false, $parent_id=false, $templates_id=false) { | |
if(!is_null($id)) { | |
$where = ""; | |
if(is_bool($id) != true) { | |
$where = " WHERE"; | |
$where .= ($parent_id) ? " parent_id = {$id}" : " id={$id}"; | |
$where .= ($templates_id) ? " AND templates_id = {$templates_id}" : ""; | |
} | |
$results = wire('db')->query("SELECT MAX(modified) as modified FROM pages{$where}"); | |
if($results->num_rows > 0) { | |
$result = $results->fetch_assoc(); | |
$search = array(' ', '-', ':'); | |
$replace = array('', '', ''); | |
return str_replace($search, $replace, $result['modified']); | |
} | |
} | |
return ""; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Added $templates_id for template filtering