This topic is locked

Calendar v2: How to add a new field to calendar monthly page

6/16/2015 2:45:14 PM
Calendar Template tips and tricks
Sergey Kornilov

This tutorial applies to Calendar v2. Before following steps in this tutorial make sure you have downloaded the latest version of Calendar template.
We'll show how to display an icon next to each event on Monthly view.


Here is how this can be done.

  1. Add a new field to calcalendar table. In our example that will be img field that stores icon URL.
  2. Modify SQL query of all views where this field needs to appear adding this new field to the list.

SELECT

id,

DateField,

...

Category,

OwnerID,

img

FROM calcalendar


3. On 'Choose fields' screen choose page where new field needs to appear i.e. Add/Edit/View pages of certain views.
4. Now proceed to <project folder>\Business\Calendar\source\include folder and open calendar_functions.php file in any text editor.
You will need to modify function function calendar_getEventHTML adding text in bold.

$strtmp = $event[calendarGetSetting("calendarSubject")];

if (strlen(trim($strtmp))==0 )

$strtmp="&lt;Empty&gt;";

if (strlen($strtmp)>$_SESSION["calendar_SubjectLength"])

$strtmp = substr($strtmp,0,$_SESSION["calendar_SubjectLength"])."...";

if ($event["img"])

$strtmp .= " <img height=16 width=16 src='".$event["url"]."'>";

S
Sergej 9/22/2015

i had an issue in phprunner 8.1 and Calendar template v2.0 - i could not display values of two fields in the monthly or weekly pages - only the value of the last field was on display - so i slightly modified calendar functions.php

like this

$strtmp1= $event[calendarGetSetting("calendarSubject")];

if (strlen(trim($strtmp1))==0 )

$strtmp1="&lt;Empty&gt;";

if (strlen($strtmp1)>$_SESSION["calendar_SubjectLength"])

$strtmp1 = substr($strtmp1,0,$_SESSION["calendar_SubjectLength"])."...";

$strtmp2 = $event[calendarGetSetting("calendarDescription")];

if (strlen(trim($strtmp2))==0 )

$strtmp2="&lt;Empty&gt;";

if (strlen($strtmp2)>$_SESSION["calendar_DescriptionLength"])

$strtmp2 = substr($strtmp2,0,$_SESSION["calendar_DescriptionLength"])."...";
$_SESSION["Prvi"]=$strtmp1;

$_SESSION["Drugi"]=$strtmp2;

$strtmp=$strtmp2.":".$_SESSION["Prvi"];
the new variables were used $strtemp1 & $strtemp2 while previously only $strtemp was enough.

i put the values of the Subject and Description to session variables

and later to the original $strtmp variable added values of $strtemp2 and one session variable though i could use both sesion variables - and have displayed in the calendar subject and description field values - while previously was only one or the other displayed depending which was last listed in this section of the code.

Hope this will help someone solve the similar problem.