WBCE Home | WBCE Hilfe | WBCE Addon Repository | Impressum | Datenschutz

WBCE CMS Forum

WBCE CMS – Way Better Content Editing.

You are not logged in.

#1 06.10.2018 12:59:18

foxlake
Member

Droplet with next prev month

Hai there,

I use the ProCalendar for a school website.  But they don't like that day don't not see the 'item' in the calender.
You originally just see another color on the date, you must click on it and then you see under it one date with the event.
And then click on that event to see the event page. (Knipsel2 jpg)

What this school want is that the see the event name in the calendar , and when they click on it the event page opens.
In the droplet 'procall' this is the case.  But in that droplet is no next month or prev moth.
Is it possible to make that in this droplet ? (kalender_droplets jpg)

So I don't have to install a calendar outside WBCE (they have seen one)

I changed the layout of the droplet all ready (see pic)  but i'm not a PHP writer, so is there someone who can make a button next / prev month in this ?

Like in the tiny calendar that is on the pic to.

Thank you in advance.

(and how do I get the months in Dutch ? of this procal droplet?)

Last edited by foxlake (06.10.2018 17:12:16)

Offline

#2 08.10.2018 14:28:50

florian
Projektmanagement und Support WBCE CMS

Re: Droplet with next prev month

Here is the code for the droplet with prev/next navigation

// parameters:
// 	 section_id : Section id from procalendar module
// on default calendar starts at Sunday and shows current month but you can custumize by using a option:
//   first_day (integer) 	: first day of week; 0 = Sunday, 1 = Monday
// 	 year (integer) : year of start date
// 	 month (integer): month of start date
//

global $database;
require_once(WB_PATH."/modules/procalendar/functions.php");

// --- config options; you may change these ---
$days=array(0=>"Sunday",1=>"Monday",2=>"Tuesday",3=>"Wednesday",4=>"Thursday",5=>"Friday",6=>"Saturday",7=>"Sunday");
$seconds_per_day 	= 60*60*24;
$weeks						= 5;
$first_day = isset($first_day) ? intval($first_day) : 0;

$events = array();
// year and month defaults
$yr = isset($year) ? intval ($year) : date('Y', time());
$mnth = isset($month) ? intval($month) : date('n', time());
if(isset($_GET['procal_next']) && $_GET['procal_next'] != "") {
	$showDate = explode("_",$_GET['procal_next']);
	$mnth = $showDate[0];
	$yr = $showDate[1];
}

$nextYear = ($mnth +1) > 12 ? $yr+1 : $yr;
$nextMonth = ($mnth +1) > 12 ? 1 : $mnth +1;
$prevYear = ($mnth -1) > 0 ? $yr : $yr-1;
$prevMonth = ($mnth -1) > 0 ? $mnth -1 : 12;
$pn = array("<&nbsp;&nbsp;&nbsp;" => $_SERVER['SCRIPT_NAME']."?procal_next=".$prevMonth."_".$prevYear, "&nbsp;&nbsp;&nbsp;>" => $_SERVER['SCRIPT_NAME']."?procal_next=".$nextMonth."_".$nextYear); // array for prev/next links;


$section_id = isset($section_id) ? intval($section_id) : 0 ;

$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";
  $page_link = WB_URL.PAGES_DIRECTORY.$database->get_one($sql).PAGE_EXTENSION;
}

$content ='';
$datestart = "$yr-$mnth-1";
$dateend = "$yr-$mnth-".cal_days_in_month(CAL_GREGORIAN, $mnth,$yr);



if (!isset($actions) || empty($actions))
  $actions  = fillActionArray($datestart, $dateend, $section_id);
if (is_array($actions)){
	foreach($actions as $row){
		// Build url like : pages/kalendar.php?year=1900&month=01&day=03&id=2&detail=1
		$ds = $row['date_start']." ".substr($row['time_start'],0,5); 
		$page_url = $page_link.'?year='.(substr($ds,0,4)).'&month='.(substr($ds,5,2)).'&day='.(substr($ds,8,2)).'&id='.$row['id'].'&amp;detail=1';
    $daystart = (int)substr($row['date_start'],-2);
    $dayend = (int)substr($row['date_end'],-2);
    $monthstart = (int)substr($row['date_start'],5,2);
    $monthend = (int)substr($row['date_end'],5,2);
    if ($monthstart<$mnth) {
      $monthstart=$mnth; 
      $daystart = 1;
    }   
    if ($monthend>$mnth) {
      $monthend=$mnth; 
      $dayend = cal_days_in_month(CAL_GREGORIAN,$mnth,$yr);
    }   
    for ($ev_day=$daystart;$ev_day<=$dayend;$ev_day++) {
    	if (isset($events[$ev_day])) {
        $events[$ev_day] .= "<a href='".$page_url."' title='".$row['name']."'>".$row['name']."</a><br />";
      } else {
      	$events[$ev_day] = "<a href='".$page_url."' title='".$row['name']."'>".$row['name']."</a><br />";
      }
    }   
  }
}

$unix_month_start=mktime(0,0,0,$mnth,1,$yr);
$cal_month = date( 'F', $unix_month_start );
$month_name_translated_array = array('','Januar','Februar','März','April','Mai','Juni','Juli','August','September','Oktober','November','Dezember');
$month_name=$month_name_translated_array[intval($mnth)];

@list($p, $pl) = each($pn); @list($n, $nl) = each($pn); #previous and next links, if applicable
if($p) $p = '<span class="calendar-prev">'.($pl ? '<a href="'.htmlspecialchars($pl).'">'.$p.'</a>' : $p).'</span>&nbsp;';
if($n) $n = '&nbsp;<span class="calendar-next">'.($nl ? '<a href="'.htmlspecialchars($nl).'">'.$n.'</a>' : $n).'</span>';

$cal_month_year = $month_name.' '.date( 'Y', $unix_month_start );
$cal_start_day=date( 'l', $unix_month_start );
$cal_days_in_month=date( 't', $unix_month_start );
$day_count=$unix_month_start;
$day_stop=$unix_month_start+($cal_days_in_month*$seconds_per_day);
$last_day = 7 + $first_day;
for($x = $first_day; $x < $last_day; $x++)
    {if($days[$x]==$cal_start_day){$start=$x;}}
$counter=$unix_month_start-(($start - $first_day) * $seconds_per_day);
$cal_days=$start+$cal_days_in_month;
if(($start+$cal_days_in_month)>35)
    {$weeks=6;}
if(($start+$cal_days_in_month)<29)
    {$weeks=4;}
$content .= "<center>";
$content .= "<table style='FONT-STYLE:normal;font-size:8mm;COLOR:blue;BACKGROUND-COLOR:#aaaaaa;font-family:Arial, Helvetica, sans-serif;font-weight:normal;text-align:center;'><tr><td>";
$content .= "<h2>".$p.$cal_month_year.$n."</h2>";
$content .= "</td></tr><tr><td>";
$content .= "<table border='1' style='FONT-STYLE:normal;font-size:3mm;COLOR:black;BACKGROUND-COLOR:#ffffff;font-family:Arial, Helvetica, sans-serif;font-weight:normal;text-align:center;'><tr>";
for($x = $first_day; $x < $last_day; $x++)
    {$content .= "<th width='75' height='25' valign='top'>".$days[$x]."</th>";}
$content .= "</tr>";
for ($week=0;$week<$weeks;$week++)
{
    $content .= "<tr>";
    for($x = $first_day; $x < $last_day; $x++){$content .= "<td width='75' height='70' valign='top' style='COLOR:black;font-size:3mm;font-weight:bold;font-family:sans-serif;'>";
    if($counter<$day_stop)
    {
      if($counter>=$unix_month_start)
      {
        $content .= "<center>".date( 'd', $counter)."</center>";
        $day=date( 'j', $counter);
        if(isset($events[$day])){	
          $content .= $events[$day];
        }
      }
      $counter+=$seconds_per_day;
    }  
    $content .= " </td>";}
    $content .= "</tr>";
}
$content .= "</table>";
$content .= "</td></tr></table><br /></center>";

return $content;

Online

#3 08.10.2018 17:43:26

foxlake
Member

Re: Droplet with next prev month

Super !  Thank you very much !     smile  thumb_up

Greetings, Foxlake

Offline

Liked by:

florian

#4 08.10.2018 20:54:38

foxlake
Member

Re: Droplet with next prev month

Oops ... when I translate the days 0=>"Sunday",1=>"Monday",2=>"Tuesday",3=>"Wednesday"
In the droplet to Maandag  Dinsdag Woensdag etc.  .. Days in every month starts on monday the 1st. 
Must this be a translate line to  ?

Thank you in advance

Offline

#5 09.10.2018 06:16:57

florian
Projektmanagement und Support WBCE CMS

Re: Droplet with next prev month

You're right, change the code in line ~13 to

$days=array(0=>"Sunday",1=>"Monday",2=>"Tuesday",3=>"Wednesday",4=>"Thursday",5=>"Friday",6=>"Saturday",7=>"Sunday");
$days_translated=array(0=>"Zondag",1=>"Maandag",2=>"Dinsdag",3=>"Woensdag",4=>"Donderdag",5=>"Vrijdag",6=>"Zatertag",7=>"Zondag");

(so we have (again) the original days array, which is needed for comparing, and a new array with the translated ones)

and then change line ~110

{$content .= "<th width='75' height='25' valign='top'>".$days[$x]."</th>";}

to

 {$content .= "<th width='75' height='25' valign='top'>".$days_translated[$x]."</th>";}

Online

#6 09.10.2018 06:33:15

foxlake
Member

Re: Droplet with next prev month

Again,  Thank you very much !  It works and is perfect.   thumb_up  smile
Greetings from Holland, Niek Foxlake

Offline

Board footer

Powered by FluxBB

up