WebsiteBaker Community Forum

WebsiteBaker Support (2.8.x) => Droplets & Snippets => Topic started by: Roych on July 13, 2016, 02:03:55 PM

Title: Procalendar show default image if none is selected.
Post by: Roych on July 13, 2016, 02:03:55 PM
Hello I hope someone can help me with this

I'm having some trouble with a droplet. I need to show a default image if none is uploaded or selected when creating an event. (default.jpg  is the image)
Righ now I have a droplet which is working fine except this. If no image is selected it shows empty space.


The droplet also shows the word TODAY if the occuring event is on pressent day. (just for info)


Code: [Select]

// if (PAGE_ID != 3) {






//:Show next #N events
//:
// Get_Concerts
global $database, $wb;






// Show how many items, defaults to 10?
if ( !isset($max) ){ $max = 10; };


// year and month and section defaults
if(!isset($year)) {$year = date('Y', time()); }
if(!isset($month)) {$month = date('n', time()); }
if(!isset($section_id)) {$section_id = 0 ; }




// Set dateformat to suit your needs, add timeformat if needed
$dateformat = 'd'; // Standard php date formats
$datemonth = 'M'; // Standard php date formats
$dateyear = 'Y'; // Standard php date formats


// Fetch base page link, if event_id = set
$extrasql = '';
$page_id = 0;
$page_link ='';


if ($section_id<>0) {
$extrasql = " section_id = '".$section_id."' AND ";
$sql = "SELECT page_id FROM ".TABLE_PREFIX."sections WHERE section_id = '".$section_id."'";
$result = $database->query($sql);
if ( $result->numRows() > 0 ) {
while( $row = $result->fetchRow() ) {
$page_id = $row['page_id'];
}
}
if ($page_id <> 0) {
$sql = "SELECT link FROM ".TABLE_PREFIX."pages WHERE page_id = '".$page_id."'";
$result = $database->query($sql);
if ( $result->numRows() > 0 ) {
while( $row = $result->fetchRow() ) {
$page_link = page_link($row['link']);
}
}
}
}










// Set start- and end date for query
// $datestart = "$year-$month-1"; ORIGINAL = show all events in this month
$datestart = date("Y-m-d"); // ALTERNATIVE = show all events in this month, starting today
$dateend = "$year-$month-".cal_days_in_month(CAL_GREGORIAN, $month,$year);


// Fetch the items
$sql = "SELECT DAY(date_start) AS day, id, custom1, custom4, date_start, time_start, date_end, time_end, name FROM ".TABLE_PREFIX."mod_procalendar_actions WHERE ".$extrasql." date_start >='$datestart' AND public_stat = 0 ORDER BY date_start,time_start LIMIT 0, ".$max." ";
$mod_query = $database->query($sql);
while ( $row =& $mod_query->fetchRow()){
// Build url like : pages/kalendar.php?id=2&detail=1
$page_url = $page_link.'?id='.$row['id'].'&amp;detail=1';
$ds = $row['date_start']." ".substr($row['time_start'],0,5);
$de = $row['date_end']." ".substr($row['time_end'],0,5);
$datetime_start = mktime(substr($ds,11,2),substr($ds,14,2),0,substr($ds,5,2),substr($ds,8,2),substr($ds,0,4));
$datetime_end = mktime(substr($de,11,2),substr($de,14,2),0,substr($de,5,2),substr($de,8,2),substr($de,0,4));
 
    $printTime = $row['time_start'];


                 
     if(date('Y-m-d',$datetime_start)==date('Y-m-d')){                   
  $mod_list.= '
 
 
 
  <div class="col-md-4 col-sm-4 featured-block">
    <a href="'.$page_url.'" class="img-thumbnail">
    <img src="'.$row["custom4"].'" alt="staff"> 
    <strong>'.$row["name"].'<span class="danes" style="color:yellow"> Today!</span></strong>
    <span class="more">Read more ...</span> </a>
   <>
  ';
  }
 
else{
$mod_list.= '<div class="col-md-4 col-sm-4 featured-block">
    <a href="'.$page_url.'" class="img-thumbnail">
    <img src="'.$row["custom4"].'" alt="staff">
    <strong>'.$row["name"].'</strong>
    <span class="more">Read more ...</span> </a>
   <>    ';
   
   
 
   
  }           
 




}




 return $mod_list;


// }


I tried with some PHP but cant figure it out as Im not a coder. :(


Thank you


R
Title: Re: Procalendar show default image if none is selected.
Post by: marmot on July 16, 2016, 06:59:40 PM
Hi,

I need to show a default image if none is uploaded or selected when creating an event. (default.jpg  is the image)
First define the default image path somewhere at the beginning of the droplet:
Code: [Select]
$pc_default_img = <put path to the image here>;I guess the you use the "custom4" field to store the image, so replace the
Code: [Select]
$row["custom4"] with
Code: [Select]
(!isset($row["custom4"]) || $row["custom4"] == "" ? $pc_default_img : $row["custom4"])
regards
Title: Re: Procalendar show default image if none is selected.
Post by: Roych on July 17, 2016, 04:42:48 PM
Hi,

I need to show a default image if none is uploaded or selected when creating an event. (default.jpg  is the image)
First define the default image path somewhere at the beginning of the droplet:
Code: [Select]
$pc_default_img = <put path to the image here>;I guess the you use the "custom4" field to store the image, so replace the
Code: [Select]
$row["custom4"] with
Code: [Select]
(!isset($row["custom4"]) || $row["custom4"] == "" ? $pc_default_img : $row["custom4"])
regards


nice it works perfect ;)
Thank you
R