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
if( !function_exists('doif') ){ function doif( $pre , $str , $strict=FALSE ){ if( !$strict ){ if( $str ) return $pre.$str; }else{ if( !is_bool($strict) ){ if( $str!==$strict ) return $pre.$str; }else{ if( $str!==FALSE ) return $pre.$str; } } return NULL; }} global $database, $wb;$mod_query = $database->query( "SELECT title, link, published_when" ." FROM ".TABLE_PREFIX."mod_news_posts" ." WHERE" ." active = ". ((isset($active)) ? $active : 1 ) .doif(" AND group_id = ", ((isset($group)) ? $group : 0 ),'false') .doif(" AND published_when >= ", ((isset($start_date)) ? strtotime($start_date) : strtotime("-10 day") )) .doif(" AND published_when <= ", ((isset($stop_date)) ? strtotime($stop_date) : strtotime("now") )) .doif(" AND page_id = " , ((isset($page)) ? $page : false ),TRUE) .doif(" ORDER BY post_id ", ((isset($order)) ? $order : "DESC" ),'false') .doif(" LIMIT ", ((isset($max)) ? $max : 10 ),'false') );$mod_list = "";while ( $row = $mod_query->fetchRow() ){ $mod_list .= '<a href="'.WB_URL.PAGES_DIRECTORY.$row["link"].PAGE_EXTENSION.'">'.$row["title"].'</a><br>';}return $mod_list;
if ( !isset($max) ){ $max = 10; }if ( !isset($start_date) ){ $start_date= "-10 day"; }if ( !isset($stop_date) ){ $stop_date= "now"; }if ( !isset($order) ){ $order= "DESC"; }global $database, $wb;$mod_query = $database->query("SELECT title, link, published_when FROM ".TABLE_PREFIX."mod_news_posts WHERE active='1' AND group_id = ".$group." AND published_when>=".strtotime($start_date)." AND published_when<=".strtotime($stop_date)." ORDER BY post_id ".$order." LIMIT ".$max);$mod_list = " ";while ( $row =& $mod_query->fetchRow()){ $mod_list .= '<a href="'.WB_URL.PAGES_DIRECTORY.$row["link"].PAGE_EXTENSION.'">'.$row["title"].'</a><br>';}return $mod_list;
global $database, $wb;$mod_query = $database->query("SELECT title, link FROM ".TABLE_PREFIX."mod_news_posts WHERE group_id = ".$group);$i = 0;while ($row =& $mod_query->fetchRow() && $i <= $max) {$i++;// To change how the links are presented, have fun with this variable $mod_list .= '<a href="'.WB_URL.PAGES_DIRECTORY.$row["link"].PAGE_EXTENSION.'">'.$row["title"].'</a><br>';}return $mod_list;
Hi KonTrax,Nice to see a first time user contribute to the Droplet library.It is a nice idea too..I made a few changes to your original Droplet.1. The Max value was interpreted with one line less than it should. (< $max is now <= $max)2. The url was not built correctly. WB_PATH was used, it should be WB_URL.Also the /pages/ and the .php extention can be modified in WB. It is better to use the defined constants PAGES_DIRECTORY and PAGE_EXTENSION to build the correct url.
I updated the Droplet in the library.It is now using $i < $ max again but the query has an extra WHERE clause to select only active items.Ruud
BTW Ruud, The Library says Example Call : [[[[GetNewsHeads?group=2&max=2]]]]
Now it actually should have an additional test for the optional start_date / end_date. That would make it perfect.Ruud
[[GetNewsHeads?group=2&max=10&start_date=-90 day&stop_date=now&order=ASC]]
if ( !isset($max) ){ $max = 10; }if ( !isset($start_date) ){ $start_date= "-10 day"; }if ( !isset($stop_date) ){ $stop_date= "now"; }if ( !isset($order) ){ $order= "DESC"; }global $database, $wb;$mod_query = $database->query("SELECT title, link, published_when FROM ".TABLE_PREFIX."mod_news_posts WHERE active='1' AND group_id = ".$group." AND published_when>=".strtotime($start_date)." AND published_when<=".strtotime($stop_date)." ORDER BY published_until ".$order." LIMIT ".$max);$mod_list = " ";while ( $row =& $mod_query->fetchRow()){ $mod_list .= '**** N E W S ****'; $mod_list .= '<a href="'.WB_URL.PAGES_DIRECTORY.$row["link"].PAGE_EXTENSION.'">'.$row["title"].'</a>';}return $mod_list.'**** N E W S ****';
Kein aktiver Inhalt auf dieser Seite vorhandenZurück
[[GetNewsHeads?group=2&max=10&start_date=-90 day&stop_date=+0&order=ASC]]
if ( !isset($max) ){ $max = 10; }if ( !isset($start_date) ){ $start_date= "-10 day"; }if ( !isset($stop_date) ){ $stop_date= "now"; }if ( !isset($order) ){ $order= "DESC"; }$txt_search="";if ( isset($pageid) ){ $txt_search= " AND page_id=".$pageid; }global $database, $wb;$mod_query = $database->query("SELECT title, link, published_when FROM ".TABLE_PREFIX."mod_news_posts WHERE active='1' AND group_id = ".$group." AND published_when>=".strtotime($start_date)." AND published_when<=".strtotime($stop_date).$txt_search." ORDER BY post_id ".$order." LIMIT ".$max);$mod_list = " ";while ( $row =& $mod_query->fetchRow()){ $mod_list .= '<a href="'.WB_URL.PAGES_DIRECTORY.$row["link"].PAGE_EXTENSION.'">'.$row["title"].'</a><br>';}return $mod_list;
$txt_search="";if ( isset($pageid) ){ $txt_search= " AND page_id=".$pageid; }
" AND published_when<=".strtotime($stop_date).$txt_search.
nice work, but i needed more...What if you have more than one news page in a web??I have 3 in mine, so i needed to list the news form every page, but in diferent places.Yeah, i know i can use groups, but it's not exactlly the same.BTW, it was so easy to modify that i couldn't resist, jejejeIf you like this, just say thanks.