scooter wrote:
Hi,
it would be great to have the possibility to add one or more category name(s) or ID(s) to the {CALENDAR} string so that only these categories are displayed in the embedded calendar.
example: {CALENDAR General} or something like that
greets
scooter
You can write: {CALENDAR;3} for a calendar with only events of category 3. Note that the function that permits this, does a global replace of all CALENDAR tags, which means that all calendars - if on the same page - will be replaced with the same calendar category.
For instance, if you want two calendars on the same page with each one different category, they would both display with the same category, namely that of the first CALENDAR tag.
I made a modification that allows for you to have multiple calendars on the same page, with each a different category. Please note that I am *not* a PHP developer and that this code is shared "as is" with no warranties or claims to be good practice or anything

Here is the new function calendar_insert($content)
Code:
// Function to deal with loading the calendar into pages
function calendar_insert($content)
{
/* Rikard changed preg_match to preg_match_all, to see if there are more than
one calendar on this page */
if (preg_match_all('/\{CALENDAR*.+\}/',$content,$dummy,PREG_PATTERN_ORDER)==1)
{
$cat_list = preg_split('/\{CALENDAR\;/',$content);
if (sizeof($cat_list) > 1) {
$cat_list = preg_split('/\}/',$cat_list[1]);
$cat_list = $cat_list[0];
$cal_output = calendar($cat_list);
} else {
$cal_output = calendar();
}
$content = preg_replace('/\{CALENDAR*.+\}/',$cal_output,$content);
}else //There were more than one!
{
// How many?
$count_cals=preg_match_all('/\{CALENDAR*.+\}/',$content,$cals,PREG_PATTERN_ORDER);
$cat_list='';$cal_output='';
// For each calendar, see if there is a calendar category after ";"
for($i=0;$i<$count_cals;$i++){
$cat_list = preg_split('/\{CALENDAR\;/',$cals[0][$i]);
if (sizeof($cat_list) > 1) {
$cat_list = preg_split('/\}/',$cat_list[1]);
$cat_list = $cat_list[0];
$cal_output = calendar($cat_list);
$cat_list=";".$cat_list;
}else{
$cal_output = calendar();
}
// Now, replace only _this_ calendar tag with its calendar content
$content = preg_replace("/\{CALENDAR".$cat_list."\}/",$cal_output,$content);
}
}
return $content;
}
It works for me (TM) and the code above is shared as an example of how it could be accomplished but it probably needs some polishing by someone who really knows PHP.
Hope it is useful.
Cheers
Rikard