[EventCalendar] The category of the post for events
Alexandre Kervalec
pixelboss at hotmail.com
Tue Dec 5 02:34:35 UTC 2006
>From: "Alexandre Kervalec" <pixelboss at hotmail.com>
>Reply-To: Support for EventCalendar plugin <eventcalendar at firetree.net>
>To: eventcalendar at firetree.net
>Subject: Re: [EventCalendar] The category of the post for events
>Date: Tue, 05 Dec 2006 01:05:17 +0000
>
>>From: Alex Tingle <alex at firetree.net>
>>Reply-To: Support for EventCalendar plugin <eventcalendar at firetree.net>
>>To: Support for EventCalendar plugin <eventcalendar at firetree.net>
>>Subject: Re: [EventCalendar] The category of the post for events
>>Date: Mon, 4 Dec 2006 21:36:24 +0000
>>
>>On Sun, 03 Dec 2006 16:51:14 +0000
>>"Alexandre Kervalec" <pixelboss at hotmail.com> wrote:
>>
>> > Hi,
>> >
>> > I'm looking for a hack to make event calendar put the post in his
>>category
>> > instead of the default category define in the options. So after I will
>>be
>> > able to list posts by categories and dates. Is there a hope for this or
>>a
>> > solution not too complicate ? I'm not a code master but it would be so
>> > cool...
>>
>>Just put you posts in additional categories. Then use a query like:
>>?ec3_after=today&cat=4
>>
>>-Alex
>>
>>--
>>:: Let me solve your problems: http://www.firetree.net/consulting/
>>:: alex.tingle AT firetree.net +44-7901-552763
>>
>>_______________________________________________
>>Blog: http://wpcal.firetree.net/
>>EventCalendar at firetree.net mailing list
>>Unsubscribe: http://penguin.firetree.net/eventcalendar
>
>
>Thanks for your help.
>I try to list events on my home page by categories :
>http://www.crht.org/matrice/
>So I can't use a specific query string. Is there a way to hack the
>ec3_get_events fonction (for example make several ec3_get_events fonctions
>like ec3_get_events_seminaires, ec3_get_events_colloques, etc) to make them
>display automaticaly events of each additional categories in different
>blocks ?
>So we could have on a same page someting like :
>
>-------------------
>Seminaires
>
>ec3_get_events_seminaires
>
>Colloques
>
>ec3_get_events_colloques
>
>Autre
>
>ec3_get_events_autre
>
>...
>-----------------------------------------
>
>It would be great for my project ...!
>
>Pix
>
>_________________________________________________________________
>Windows Live Spaces : créez votre Space à votre image !
>http://www.windowslivespaces.fr/
>
>
>_______________________________________________
>Blog: http://wpcal.firetree.net/
>EventCalendar at firetree.net mailing list
>Unsubscribe: http://penguin.firetree.net/eventcalendar
Is it a good hack (I have made 3 changes but I'm not great on code / look
what it is between // pix and ///pix) ? Is there an obvious mistake ? :
<?
/** Template function. Call this from your template to insert a list of
* forthcoming events. Available template variables are:
* - template_day: %DATE% %SINCE% (only with Time Since plugin)
* - template_event: %DATE% %TIME% %LINK% %TITLE% %AUTHOR%
*/
function ec3_get_events_seminaires(
$limit,
$template_event=EC3_DEFAULT_TEMPLATE_EVENT,
$template_day =EC3_DEFAULT_TEMPLATE_DAY,
$date_format =EC3_DEFAULT_DATE_FORMAT,
$template_month=EC3_DEFAULT_TEMPLATE_MONTH,
$month_format =EC3_DEFAULT_MONTH_FORMAT
// pix
$additional_category =EC3_DEFAULT_ADDITIONAL_CATEGORY
///pix
)
{
if(!ec3_check_installed(__('Upcoming Events','ec3')))
return;
global $ec3,$wpdb,$wp_version;
// Parse $limit:
// NUMBER - limits number of posts
// NUMBER days - next NUMBER of days
if(empty($limit))
{
$limit_numposts='LIMIT 5';
}
elseif(preg_match('/^ *([0-9]+) *d(ays?)?/',$limit,$matches))
{
$secs=intval($matches[1])*24*3600;
$and_before="AND start<='".ec3_strftime('%Y-%m-%d',time()+$secs)."'";
}
elseif(intval($limit)<1)
{
$limit_numposts='LIMIT 5';
}
else
{
$limit_numposts='LIMIT '.intval($limit);
}
if(!$date_format)
$date_format=get_settings('date_format');
// pix
if(!$additional_category)
$additional_category=$event_category;
/// pix
// Find the upcoming events.
$calendar_entries = $wpdb->get_results(
"SELECT DISTINCT
p.id AS id,
post_title,
start,
u.$ec3->wp_user_nicename AS author,
allday
FROM $ec3->schedule s
LEFT JOIN $wpdb->posts p ON s.post_id=p.id
LEFT JOIN $wpdb->users u ON p.post_author = u.id
WHERE p.post_status='publish'
AND end>='$ec3->today' $and_before
// pix
AND $cat=$additional_category
/// pix
ORDER BY start $limit_numposts"
);
echo "<ul class='ec3_events'>";
echo "<!-- Generated by Event Calendar v$ec3->version -->\n";
if($calendar_entries)
{
$time_format=get_settings('time_format');
$current_month=false;
$current_date=false;
$data=array();
foreach($calendar_entries as $entry)
{
// To use %SINCE%, you need Dunstan's 'Time Since' plugin.
if(function_exists('time_since'))
$data['SINCE']=time_since( time(), ec3_to_time($entry->start) );
// Month changed?
$data['MONTH']=mysql2date($month_format,$entry->start);
if((!$current_month || $current_month!=$data['MONTH']) &&
$template_month)
{
if($current_date)
echo "</ul></li>\n";
if($current_month)
echo "</ul></li>\n";
echo "<li class='ec3_list ec3_list_month'>"
. ec3_format_str($template_month,$data)."\n<ul>\n";
$current_month=$data['MONTH'];
$current_date=false;
}
// Date changed?
$data['DATE'] =mysql2date($date_format, $entry->start);
if((!$current_date || $current_date!=$data['DATE']) && $template_day)
{
if($current_date)
echo "</ul></li>\n";
echo "<li class='ec3_list ec3_list_day'>"
. ec3_format_str($template_day,$data)."\n<ul>\n";
$current_date=$data['DATE'];
}
if($entry->allday)
$data['TIME']=__('all day','ec3');
else
$data['TIME']=mysql2date($time_format,$entry->start);
$data['TITLE'] =$entry->post_title;
$data['LINK'] =get_permalink($entry->id);
$data['AUTHOR']=$entry->author;
echo " <li>".ec3_format_str($template_event,$data)."</li>\n";
}
if($current_date)
echo "</ul></li>\n";
if($current_month)
echo "</ul></li>\n";
}
else
{
echo "<li>".__('No events.','ec3')."</li>\n";
}
echo "</ul>\n";
}
?>
_________________________________________________________________
Live.com : le moteur de recherche aux réponses bien carrossées!
http://www.windowslive.fr/livecom/
More information about the EventCalendar
mailing list