|
Creating a custom event view |
|
We will use extrovert/tutorirals/examples/chess_club/index2.php
as an example site. Note that you can click on event titles in the example site.
We'll cover the following topics:
- Creating a custom event view page.
An advanced version of creating an event display is examplified in
Development Tutorial 1.
Custom Event View
We'll take our example used in the Embedding a Calendar
tutorial and
add custom event view functionality.
Instead of recreating and publishing the calendar again, we can simply change/add a few
options.
Change:
$cal->set("event_links", 0);
to
$cal->set("event_links", 1);
Then add:
$cal->set("event_view_url", "view.php?eid=%eid&inst=%inst");
below it.
In the Calendar Publisher, this is the equivalent of checking the 'Event Links' option
and changing 'Event Link URL' to view.php?eid=%eid&inst=%inst
under the 'Events' section.
Now we must create view.php. We'll need to copy and paste a few things from our main
calendar page. Optionally we can use the calendar publisher again. We'll need the lines:
############################################################
# base path of thyme with trailing slash
define("_CAL_BASE_PATH_", "/usr/local/apache/htdocs/thyme/");
# base url of thyme with trailing slash
define("_CAL_BASE_URL_", "http://192.168.1.111:80/thyme/");
require_once(_CAL_BASE_PATH_ . "include/classes/class.calendar.php");
############################################################
$cal = new calendar();
Then we'll add the line:
$e = $cal->get_event($_REQUEST['eid'], $_REQUEST['inst']);
This will collect the event information. $_REQUEST['eid'] simply means 'eid' as set in the
request. Same for inst. Remember that we set 'event_view_url' to view.php?eid=%eid&inst=%inst. eid is the event's id and inst is the event's date instance. Thyme needs the date instance to correctly set relative timezone information.
$e now contains all the information listed in the Event Variables section of the API Reference.
In the body of view.php we can simply display (or echo()) any of the event information.
I've used the following code to do this:
<table width='300' align='center' style=' border: 1px solid #fff; padding: 0px; border-collapse: collapse '> <tr valign='middle'> <td align='center' bgColor='#000000'> <h2><?php echo($e->title); ?></h2> <hr> </td> </tr>
<tr> <td align='left'> <?php echo(nl2br($e->notes)); ?>
<br /><br />
<b><font color='#000000'>Address:</font></b><br /> <?php echo($e->addr_st); ?><br /> <?php echo($e->addr_ci); ?><br /> <br /> <b><font color='#000000'>Phone:</font></b> <?php echo($e->phone); ?> <br /><br />
</td> </tr> </table> <br />
For those not familiar with PHP, nl2br (used on the event notes)
converts new lines to <br> so that it displays correctly in HTML.
The event view page is now created and will change depending on which event
was selected on the main calendar page.
View entire source:
View example site:
|