WebsiteBaker Community Forum
WebsiteBaker Support (2.8.x) => Droplets & Snippets => Topic started by: pcwacht on November 04, 2009, 11:48:43 AM
-
I needed a list of pages whith last x modified pages
Used the droplet SiteModifiedX but wasn't happy with it -> http://www.websitebakers.com/pages/droplets/official-library/information/site-modified-x.php
The snippet Last Modified Pages Advanced was more what I need -> http://www.websitebakers.com/pages/code-snippets/listings/last-mod-pages-adv..php
So I merged the two ;)
<?php
global $database, $wb;
$links = "";
$heute = floor(time() / 86400);
$bisher = -1;
if(!isset($x)){$x=10;};
if (PAGE_ID>0) {
$query = $database->query("SELECT modified_when, link,page_title WHERE visibility='public' FROM ".TABLE_PREFIX."pages order by modified_when desc limit $x");
while($mod_details=$query->fetchRow()){
$tag =floor($mod_details['modified_when'] / 86400);
$aktuell = $heute - $tag;
if ($aktuell > 3) { $aktuell = 3; }
if ($aktuell < 3) {
$aenderungsdatum= date("H:i ", $mod_details['modified_when']);
} else {
$aenderungsdatum= date("d. M Y ", $mod_details['modified_when']);
}
$weblink=$mod_details['link'];
$cutzeichen=strrpos($weblink,"/");
$weblinktext = substr($weblink,0,$cutzeichen);
if ($weblinktext == "")
{
$weblink_text = "(in Mainmenu)";
}
else
{
$weblink_text = "(in " . str_replace('/', ' > ', $weblinktext) . ")";
}
if ($bisher <> $aktuell)
{
$bisher = $aktuell;
switch ($aktuell)
{
case 0: $links.= "<h4 class='lastchanges'>Today:</h4>\n"; break;
case 1: $links.= "<h4 class='lastchanges'>Yesterday:</h4>\n"; break;
case 2: $links.= "<h4 class='lastchanges'>Day before yesterday:</h4>\n"; break;
case 3: $links.= "<h4 class='lastchanges'>Older then three days:</h4>\n"; break;
}
}
$links.= $aenderungsdatum ." <a href=\"" . WB_URL . PAGES_DIRECTORY . "$weblink.php\"><b>" . $mod_details['page_title'] . "</b></a> ". $weblink_text . "<br />\n";
}
return $links;
}
It can use one optional parameter $x for number of pages to show, if omitted 10 are shown.
call: [[SiteModifiedAdvancedX?x=15]]
Have fun,
John