WebsiteBaker Community Forum

WebsiteBaker Support (2.8.x) => Droplets & Snippets => Topic started by: Roych on September 12, 2014, 08:22:44 PM

Title: Procalendar droplet language & image help?
Post by: Roych on September 12, 2014, 08:22:44 PM
Hello all

I opened another topic cause I asked in an old one and don't know if anybody saw that.  I'm kinda lost here  :?
Older thread: http://www.WebsiteBaker.org/forum/index.php/topic,25116.0.html

So i have a problem with procalendar droplet changing language on a multilanguage site.
I went through all language files in my WB and couldn't find the right one. I dont know from where the droplet is fetching language...

So far I have made two same droplets one for the Slovenian "SI" (eventlistslo) and one for English "EN" (eventlisteng) procalendar. And I use two procalendar modules one for each language.

my droplet: SI
Code: [Select]
//:Show next $max events
//:only section_id of procal installation is required
//:get categorie id from categorie link or form procal database
//:usage: [[eventlist?section_id=<xx>&datestart=<yyyy-mm-dd>&dateend=<yyyy-mm-dd>&kat=<categorie id>&max=<max entries to show>]]
// Get events
global $database, $wb;
require_once(WB_PATH."/modules/procalendar/functions.php");



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

// year and month and section defaults
if(!isset($datestart))  {$datestart  = date('Y-n-d', time()); }
if(!isset($dateend)) {$dateend = date('Y-n-d', time()); }
if(!isset($section_id)) {$section_id = 0 ; }
if(isset($_GET['categorie'])) {$kat = $_GET['categorie'];}

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

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

// Fetch the items
if (!isset($actions) || empty($actions))
  $actions  = fillActionArray($datestart, $dateend, $section_id);
$mod_list = "";//print_r($actions); 


// KEVIN NEW
$categories = array();
if (is_array($actions)){
foreach($actions as $row){
$categories[$row['acttype']] = array($row['act_name'],$row['act_format'],$row['acttype']);
if (isset($kat) && $kat !== $row['acttype']) continue;
   $page_url = $page_link.'?id='.$row['id'].'&amp;detail=1';
 }
}
$mod_list.= '<div class="proCalCategoryContainer"><div class="proCalFilter">Prikaži Samo:</div>';
foreach ($categories as $cat) {
$link = '?categorie='.$cat[2];
$mod_list.='<div class="proCalCategory" style="background:'.$cat[1].'";><a href="'.$link.'">'.$cat[0].'</a></div>';
}
$mod_list.='<div class="proCalCategory"><a href="?">Prikaži Vse</a></div><div class="clear"></div></div>';
// END KEVIN NEW


$mod_list .= '<table class="proCalTable">';

$printDay = "";
$categories = array();
if (is_array($actions)){
foreach($actions as $row){
$categories[$row['acttype']] = array($row['act_name'],$row['act_format'],$row['acttype']);
if (isset($kat) && $kat !== $row['acttype']) continue;
   // Build url like : pages/kalendar.php?id=2&detail=1   
   $page_url = $page_link.'?id='.$row['id'].'&amp;detail=1';
   if ($row['date_start'] !== $printDay) {
    $printTime = "";
    if ($printDay !== "") $mod_list.= '</td></tr>';
    $printDay = $row['date_start'];
    $mod_list.= '<tr><td colspan = 2><div class="proCalDate"><span class="proCalDateBig">'.date('l', strtotime($printDay)).' </span><span class="proCalDateSmall">'.date('F j', strtotime($printDay)).'</span></div>';
   }
   
   if ($row['time_start'] !== $printTime) {
    $printTime = $row['time_start'];
    $mod_list.= '</td></tr><tr><td class="proCalTime"><span class="proCalTimeStart">'.substr($printTime,0,5).'</span></td><td>';
    //$mod_list.= '</td></tr><tr><td class="proCalTime"><span class="proCalTimeStart">'.substr($printTime,0,5).'</span></td><td>';tr><tr><td width="40px"><span class="timeStart">'.substr($printTime,0,5).'</span></td><td>';
   }
 
   $mod_list .= '<p class="proCalBand" style="background:'.$row["act_format"].'";><a target="_blank" href="'.$page_url.'"><b>'.$row["name"].'</a></p>'; //.$page_url.
 }
}


$mod_list.= '</td></tr></table>';

$mod_list.= '<div class="proCalCategoryContainer"><div class="proCalFilter">Prikaži Samo:</div>';
foreach ($categories as $cat) {
$link = '?categorie='.$cat[2];
$mod_list.='<div class="proCalCategory" style="background:'.$cat[1].'";><a href="'.$link.'">'.$cat[0].'</a></div>';
}
$mod_list.='<div class="proCalCategory"><a href="?">Prikaži Vse</a></div><div class="clear"></div></div>';
return $mod_list;

Problem is that weekdays and dates are always in english.


And another question, I want is to have a little image with some class (to style it) in every event (with the same link as event) and don't know how to modify the droplet to do that the same as shown on a posted image. Can this be done?

I think somewhere here: ??
Code: [Select]
 
 
   $mod_list .= '<p class="proCalBand" style="background:'.$row["act_format"].'";><a target="_blank" href="'.$page_url.'"><b>'.$row["name"].'</a></p>'; //.$page_url.
 }


Image should be uploaded when you create a new event through a custom "add image" field which I already have. (CUSTOM4).

I posted images so you can see what I mean.


I tried everything I could think off, but I'm not a coder so I'm staying stuck here. 

Any help would be really appreciated

Thank you very much

R.
Title: Re: Procalendar droplet language & image help?
Post by: Roych on September 13, 2014, 12:06:27 PM
Ok, I somehow made it with an image  :-P

Its, working great ;)
Here is what I did.
Code: [Select]
$mod_list .= '<p class="proCalBand" style="background:'.$row["act_format"].'";><a target="_blank" href="'.$page_url.'"><img src="'.$row["custom4"].'" class="slikca" /></a><a target="_blank" href="'.$page_url.'"><b>'.$row["name"].'</a></p>'; //.$page_url.
 }

But the language still stays mistery to me??? Anyone?

thx.

R.

Title: Re: Procalendar droplet language & image help?
Post by: marmot on September 14, 2014, 01:04:12 PM
Hi,

thanks for using my droplet.
Ok, I somehow made it with an image
sometimes it just needs a bit of patience, time and effort to manage problems  8-)
Quote
Here is what I did...
thanks for letting us know your solution.
Quote
But the language still stays mistery to me??? Anyone?
there are several ways. As you created a droplet for each language you can hard code the text inside. So I guess the problem is just with the names of weeks and months.
They are created by PHP and so one Idea is to use the set_locale (http://php.net/manual/de/function.setlocale.php) and strftime (http://php.net/manual/de/function.strftime.php). Somewhere in the beginning of the droplet code put
Code: [Select]
setlocale ( LC_TIME, ['de_DE', 'deu'] ); using the language codes for your language.
Patch line ~68 of the droplet to
Code: [Select]
$mod_list.= '<tr><td colspan = 2><div class="proCalDate"><span class="proCalDateBig">'.strftime('%A', strtotime($printDay)).' </span><span class="proCalDateSmall">'.strftime('%B %d', strtotime($printDay)).'</span></div>';That's it.

regards
Title: Re: Procalendar droplet language & image help?
Post by: Roych on September 14, 2014, 05:18:45 PM
Wooow, Its working like a charm now ;) You are the greatest. Saved me from my anoying client  :roll:


Didn't event thought about setlocale...  :|

Code: [Select]
setlocale( LC_TIME,"sl_SI.utf-8");
This is what 's working for me.

Thank you I like the droplet very much ;) Looks and works awesome ;) And great for visitors exactly what I wanted.

Great work, will save it locally for further use ;)

Roych
Title: Re: Procalendar droplet language & image help?
Post by: Roych on October 29, 2014, 03:32:28 PM
HelloI just wanted to update that image problem if someone will need it. ;)

Assuming that image is added with upload image function when creating a new event. [CUSTOM4] ...

Changed the code in droplet from:
Code: [Select]
$mod_list .= '<p class="proCalBand" style="background:'.$row["act_format"].'";><a target="_blank" href="'.$page_url.'"></a><a target="_blank" href="'.$page_url.'"><b>'.$row["name"].'</a></p>'; //.$page_url.


to:
Code: [Select]
if(isset($row['custom4']) && $row['custom4']) {
    // custom4 exists
    $mod_list .= '<p class="proCalBand" style="background:'.$row["act_format"].'";><a target="_blank" href="'.$page_url.'"><img src="'.$row["custom4"].'" class="eventimage" /></a><a target="_blank" href="'.$page_url.'"><b>'.$row["name"].'</a></p>'; //.$page_url.}
} else {
    // custom4 doesn't exist
    $mod_list .= '<p class="proCalBand2" style="background:'.$row["act_format"].'";><a target="_blank" href="'.$page_url.'"><b>'.$row["name"].'</a></p>'; //.$page_url.}


}

so now it doesn't show the empty space if the image is not added when creating an event ;) Add a class for image (eventimage) ...



Cheers ;)

R
Title: Re: Procalendar droplet language & image help?
Post by: Roych on February 11, 2015, 03:01:37 PM
Hello Im having a strange problem with a procalendar droplet.

Droplet itself is working fine, but it is not showing all events...

I have two events one starts on 18.march.2015 and one starts 19.march.2015 and both start at 15:30h but it only shows me the first one!

Can't find the problem here.  :? Now I had to give the second one to start at 15:31 and now it is shown. I need all events to show no matter what time they are. Where is the problem?

Here is the droplet code:
Code: [Select]
//:Show next #N events
//:
// Get_Concerts
global $database, $wb;

setlocale (LC_ALL, 'sl_SI.UTF-8'); //za vse kategorije
setlocale (LC_TIME, 'sl_SI.UTF-8'); //za datumske funkcije

// 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);
$mod_list = "";

// Fetch the items
$sql = "SELECT DAY(date_start) AS day, id, custom1, 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));
if ($row['time_start'] !== $printTime) {
    $printTime = $row['time_start'];
 
 
 
 
$mod_list.= '<ul class="upcoming-events"><li>
<div class="date"><span><span class="day">'.date($dateformat,$datetime_start).'</span><span><span class="month">'.date($datemonth,$datetime_start).'</span><span><span class="year">'.date($dateyear,$datetime_start).'</span>
</div>';

$mod_list.= '<div class="event-content"><h6><a href="'.$page_url.'">'.$row["name"].'</a></h6>
<ul class="event-meta"><li><i class="fa fa-clock-o">&nbsp;&nbsp;</i>'.substr($printTime,0,5).'<sup>h</sup></li>
<!-- <li><i class="fa fa-info-circle">&nbsp;&nbsp;</i>'.$row["custom1"].'</li> --></ul></div></li></ul>';


   }
$mod_list .= "<hr>";
 
}
$mod_list .= '<a href="[wblink13]" class="button transparent button-arrow" style="margin-top:-10px;">Napovednik</a><br></br>';
 
 return $mod_list;

Im calling it with:
Code: [Select]
[[procal-events?section_id=73&amp;max=20]]
Im posting an image so u can see what I mean.

Here is the site link:
http://www.bi-center.eu (http://www.bi-center.eu)

Thank you

R.
Title: Re: Procalendar droplet language & image help?
Post by: marmot on February 17, 2015, 05:58:13 PM
Hi,

Where is the problem?
sounds strange. If you are really after a solution please grant admin AND ftp rights and I'll try to solve the problem.

regards
Title: Re: Procalendar droplet language & image help?
Post by: Roych on February 18, 2015, 09:19:52 AM
hello

The problem is that if I have two events and they both starts at the same hour, then only one will show.
I need all events to be shown no matter which date or hour are they.

thank you

R.
Title: Re: Procalendar droplet language & image help?
Post by: Roych on March 18, 2015, 12:40:07 AM
Hello

Im still looking for this, anyone??
I know it has to be something wrong with the droplet but can't find the problem.

@Marmot: sry can't do that.

Thank you

R.