Showing recently edited pages
Some developers may need to show the list of pages that were the most recently updated in concrete5. This code snippet should help you doing this or similar tasks.
So, open the file of your concrete5 theme and add the code snippet specified below. Or you can create a block with such code. Or just simply wait till we release such block the next week or so.;-)
// output section title print '<h3>Pages recently updated</h3>'; # load helper for database $db = Loader::db(); # load helper for navigation (URLs) $nh = Loader::helper('navigation'); # number of the pages to retrieve $pages_num = 5; # let's get the pages $query = "SELECT cID, cvID, cvName, cvHandle, cvDatePublic, cvComments, cvIsApproved, cvIsNew, cvAuthorUID, cvApproverUID, cvActivateDatetime, cvDateCreated FROM CollectionVersions WHERE cvIsApproved = 1 AND cvComments != 'Initial Version' ORDER BY cvDateCreated DESC LIMIT ".intval($pages_num); $r = $db->query($query); if ($r) { while ($row = $r->fetchRow()) { $recent_page = Page::getByID($row['cID']); if ($row['cID'] != 1) { $page_link = $nh->getLinkToCollection($recent_page); } else { $page_link = DIR_REL.'/'; } # user object - author of the latest edit $page_author = User::getByUserID($row["cvAuthorUID"]); # author username $page_author_username = $page_author->getUserName(); # printing record. change the formatting if you like print ' '.$row["cvName"].'
By '.$page_author_username.', '.$row["cvDateCreated"].'
'; } }
Categories: concrete5 for developers