WebsiteBaker 2.13.8 is now available!
R.I.P Dietmar (luisehahne) and thank you for all your valuable work for WBhttps://forum.websitebaker.org/index.php/topic,32355.0.html
// Set default valuesif ( !isset($page_id) ) {$page_id=4;}if ( !isset($date_option) ) {$date_option=1;}if ( !isset($group_header) ) {$group_header='<h1>Categorie:</h1>';}if ( !isset($history_header) ) {$history_header='<h1>Archive:</h1>';}if ( !isset($display_option) ) {$display_option=0;}// Set globalsglobal $wb, $database;//get link to the page$query = "SELECT link FROM " .TABLE_PREFIX ."pages WHERE page_id=$page_id;";$result = $database->query($query);if($result->numRows() > 0){ $link = $result->fetchRow(); $page_link = $link['link'];}$output=''; $t = time();$page_id = (int) $page_id;if($display_option==0 or $display_option==2){ //show categories // query to obtain categories for the selected page $query = "SELECT * FROM " .TABLE_PREFIX ."mod_news_groups WHERE page_id=$page_id AND active=true;"; // make database query and obtain active groups and amount of posts per group $result = $database->query($query); if($result->numRows() > 0){ if ($group_header != "") { $output .= $group_header; } while($group = $result->fetchRow()){ $id = $group['group_id']; $query_detail = "SELECT * FROM " .TABLE_PREFIX ."mod_news_posts WHERE page_id=$page_id AND active=true AND group_id=$id". " AND (published_when = '0' OR published_when <= $t)". " AND (published_until = 0 OR published_until >= $t) ;"; $detail_result = $database->query($query_detail); $num = $detail_result->numRows(); if ($num>=1) { $output .= "<a href=\"" .WB_URL.PAGES_DIRECTORY .$page_link .PAGE_EXTENSION ."?g=".$group['group_id']."\">" .$group['title'] ."</a> (".$num.")<br />\n"; } } } $output1 = $output;}if($display_option==0 or $display_option==1){ //show history //determine sorting method switch($date_option){ case 0: $date = "posted_when"; break; case 1: $date = "published_when"; break; } $output = ""; //query to obtain history per month for the selected page $query = "SELECT MONTHNAME(FROM_UNIXTIME(".$date.")) as mo,MONTH(FROM_UNIXTIME(".$date.")) as m,FROM_UNIXTIME(".$date.",'%Y') as y,COUNT(*) as total FROM " .TABLE_PREFIX ."mod_news_posts WHERE page_id=$page_id AND active=true ". " AND (published_when = '0' OR published_when <= $t)". " AND (published_until = 0 OR published_until >= $t)". " GROUP BY y,m ORDER BY y DESC,m DESC;"; $result = $database->query($query); if($result->numRows() > 0){ if ($history_header != "") { $output .= $history_header; } while($history = $result->fetchRow()){ $output .= "<a href=\"" .WB_URL.PAGES_DIRECTORY .$page_link .PAGE_EXTENSION ."?y=".$history['y']."&m=".$history['m']."&method=".$date_option."\">" .$history['mo']." ".$history['y']."</a> (".$history['total'].")<br />\n"; } } $output2 = $output;}return $output1."<br / ><br />".$output2;
// Check if we should only list posts from a certain group if(isset($_GET['g']) AND is_numeric($_GET['g'])) { $query_extra = " AND group_id = '".$_GET['g']."'"; } else { $query_extra = ''; } // Get settings
// Check if we should only list posts from a certain group if(isset($_GET['g']) AND is_numeric($_GET['g'])) { $query_extra = " AND group_id = '".$_GET['g']."'"; } elseif(isset($_GET['m']) AND is_numeric($_GET['m']) AND isset($_GET['y']) AND is_numeric($_GET['y']) AND isset($_GET['method']) AND is_numeric($_GET['method'])){ $startdate = mktime(0,0,0,$_GET['m'],1,$_GET['y']); $enddate = mktime(0,0,0,$_GET['m']+1,1,$_GET['y']); switch($_GET['method']){ case 0: $date_option = "posted_when"; break; case 1: $date_option = "published_when"; break; } $query_extra = " AND ".$date_option." >= '$startdate' AND ".$date_option." < '$enddate'"; } else { $query_extra = ''; } // Get settings