
UPDATE 25-06-07: There seem to be some issues in recent versions of CMSMS, please read the entire thread before implementing.
I was looking at some of the suggestions for the calendar module over at the forge and noticed an entry by stopsatgreen (Stopsatgreen's request) asking for the calendar to use the hCalendar microformat.
I use the odd microformat, especially hCard, and thought this would also be a cool addition.
NOTE: Anybody wondering what I'm talking about should look at http://microformats.org/, http://microformats.org/wiki/hcard and http://microformats.org/wiki/hcalendar to find out more.
But put simply, microformats are a way to make information you put into a webpage readable by both humans and machines.
Why would you want to do this? Well, you can markup your contact details with hCard, then people can use browser extensions / add-ons such as Operator and Tails for Firefox. You can then view and export these contacts, look them up on a map, save them or whatever.
So, as I thought this would be nice functionality, and I know Elijah is busy and already puts so much into this (as does everyone involved with CMSMS

And I managed to make a good start! This post outlines how to update the Calendar module to include the two new fields needed, 'location' and 'url' (a url for information on the event) and the user defined tag needed to embed the hCalendar.
Please note, this doesn't integrate the hCalendar into the core of the module, there are issues with this I'll explain later, it simply allows people to embed a hidden hCalendar if they wish to, which has it's own issues too.
DISCLAIMER: I'm not a developer, I just like learning new things and trying them in the spirit of things being open source. The following changes have been 'loosely' tested and could have odd results. It also requires new fields to be added to the database. This could cause problems. You should not attempt this unless you know what you are doing or are happy you can undo the changes easily. So make backups. The idea is to help out abit with the module, and open up discussion on microformats.
I'm running CMSMS version 1.0.6 and Calendar version 0.7.8. This hasn't been tried on any other versions.
--------------------------------------------------------
PART 1: Add fields to the database
We need to add two new fields to hold the information for 'location' and 'url'. I did this using phpMyAdmin as I'm a noob

To do this in phpMyAdmin:
1. Go to the location of phpMyAdmin from your account and login (I can just go there from cPanel)
2. Select your CMSMS databse from the dropdown menu in the top left.
3. From the tabs along the top of the screen, choose 'Structure', this will list all the tables in the database.
4. Scroll down and find the entry called 'cms_module_calendar_events', follow it's row along and click the 'structure' icon, looks like this

5. The next screen shows the structure of the table. About half way down there is a row called 'Add'. Enter a '2' in the box, select the 'after' radio button and then 'event_title' from the dropdown box. Click 'GO'.
6. The next page should have two sets of rows for our new fields. Enter the following:
Field Type Length/Values Collation Attributes Null Default Extra
event_location VARCHAR 255 latin1_swedish_ci - Null NULL -
event_url VARCHAR 255 latin1_swedish_ci - Null NULL -
And click 'save'
Does that make sense? Well theres a screenshot here if it doesn't.
7. That's it! The new fields should appear on the next screen after 'event_title'.
--------------------------------------------------------
PART 2: Upload & Update Calendar Module files
I made changes to the following files:
- ROOT/Modules/Calendar/function.admindisplaymanageevents.php
- ROOT/Modules/Calendar/action.admin_add_event.php
- ROOT/Modules/Calendar/Calendar.module.php
- ROOT/Modules/Calendar/Lang/en_US.php
NOTE: I've commented all the changes in the files with a prefix of '@URMOD' so they can be searched. Theres only a handfull.
--------------------------------------------------------
PART 3: Create a user defined tag to embed your hCalendar.
To create the UDT, do the following:
1. Create a new user defined tag called 'hCalendar' or whatever you prefer.
2. Copy and paste in the following code:
Code: Select all
// hCalendar UDT v0.1
// Created on: 25-05-07
// More info on the hCalendar format can be found at: http://microformats.org/wiki/hcalendar
// get global values and assign the template variable array 'event' to $event
global $gCms;
$event = $gCms->smarty->get_template_vars(event);
// pull the parameters from the $event array and assign to their own variables
$id = $event[event_id];
$title = $event[event_title];
$location = $event[event_location];
$url = urlencode($event[event_url]);
$summary = $event[event_summary];
$details = $event[event_details];
$event_start = $event[event_date_start];
$event_end = $event[event_date_end];
// output the hCalendar markup
// use conditions to ensure there's no empty tags for valid XHTML
echo "<div style='display: none;' class='vevent' id='hcalendar-event-$id'>";
if($event_url != "")
echo "<a class='url' href='$url'>";
echo "<abbr class='dtstart' title='$event_start'>$event_start</abbr>";
// if $event_end is not empty, output the 'dtend' tag
if($event_end != "")
echo "<abbr class='dtend' title='$event_end'>$event_end</abbr>";
echo " <span class='summary'>$title</span>— at ";
// if $location is not empty, output it's tag
if($location != "")
echo " <span class='location'>$location</span>";
// else output an undisclosed message
else
echo "<span class='location'>Undisclosed</span>";
if($event_url != "")
echo " </a>";
// if summary is not defined, use full description ($details)
if($summary != "")
echo " <div class='description'>$summary</div>";
else
echo "<div class='description'>$details</div>";
echo "</div>";
3. Save your tag
4. Add the tag to your calendar 'event template', preferably right at the bottom.
5. Save / Update your template and view the page. Tails and Operator should like up with that familiar green!
NOTE: You can also use the new fields anywhere in your templates by using '{$event.event_location}' and {$event.event_url}.
So, let me know what you think. The issues with this, as I mentioned before are:
- The markup is embedded and hidden using css.
- If css is disabled, the output is duplicated
- It's longwinded, really.
- It can only really be used in the 'event template'
You could build this directly into the core, but this then forces users to use micoformat markup. Therefore, there would have to be a way for them to 'opt in' and choose the microformat.
Ideally, I'd like to build a 'Microformat Manager Module' which allows users to create different types of microformat, call them at will using a tag and also allow other modules to tap into them. For example, it would be really useful to be able to store hCards in the db, and just pull them out using a {microformat type="hcard" style="hidden" alias="under-radar"} kind of tag.
If anyone is up for helping with this, let me know. If I can get my head around how to build a module, and find some time, I'll have a go.
Please criticise this! Microformats are abit of a debate as to their usefulness anyway. Is there a need for this functionality, or is it still part of the fringe of web users and semantics freaks?
Thanks again to Rob Allen for his hard work on Calendar, any everyone else involved. Hope you aren't offended by me hacking your code

D
[gelöscht durch Administrator]