How do you publish links to events?For Drupal, you can create a block and configure it to support PHP code. The following code snippet should work for listing upcoming events. This solution organizes them by date, so modify if that does not suit you. Upcoming CiviEvents.block Of course there are other ways to do this as well. This just being one of them [Source. ] Getting a feed of events without using the APIThe iCalendar feed is the only "built-in" mechanism for getting a list of events. You can reference the iCal link for your site at this URL: http://servername.domain/civicrm/event/ical?reset=1&page=1
|
Labels

14 Comments
Hide/Show CommentsOct 08, 2007
Julia Kulla-Mader
Thanks for the code. I modified it slightly to only display public, active events.
To only display events that are active and public, change
to the following:
Oct 09, 2007
David Greenberg
Julia - Excellent addition to the code. I've updated it inline.
Oct 19, 2007
Rick Destree
Thanks for the code - it works exactly like I needed! Don't know if it was intended or not, but on my site it was duplicating things when two events had the same start date untill I changed:
to:
Nov 21, 2007
Ken Lyle
How is this configuration of a block to support PHP code accomplished?
Thanks,
Ken
Jan 27, 2008
Ruby Sinreich
You may have already figured this out, but set the input-type (right under where you paste the code) to 'PHP code.' I fyou don't see this option, go to yoursitename.org/admin/settings/filters and make sure your role has permission to use the appropriate filter.
Jan 27, 2008
Ruby Sinreich
Thank you Judy, David, and Julia (fast becoming my personal drupal goddess), this is just what I needed!
I can't believe this isn't a built-in function! I spent hours looking for a way to do it.
Apr 17, 2008
Trevor James
If you want to display the end date you can change this line of code
if ($last != $startdate) {
$display = '<br /><b>'.$startdate.'</b><br />';to:
if ($last != $startdate) {
$display = '<br /><b>'.$startdate.'</b> - <b>'.$enddate.'</b><br />';
Apr 17, 2008
Trevor James
Questions:
1) How do you tweak the PHP so that if the event just occurs on one day and not from a date to a date, you can output the date header to just show that one day ... but still have the string of start to end date for those events that run over a period of time.
2) Additionally how do you delete the second month (for end date) if the month is the same as the start date. So instead of:
Apr 17 - Apr 20 2008
it would be:
Apr 17-20 2008
3) How do you output the month to be spelled out "April" vs. "Apr"
4) Finally how would I output the City, State/Province, and Country location data? Should I add those variables to this line:
$display .= l($title_place.' '.$title_desc, 'civicrm/event/info', array(), 'reset=1&id='.$event['id']).'<br />';
echo $display;
Nov 04, 2008
kami brooks
This is how i did it. I got rid of the day of week, then did what's posted below. It doesn't specifically test that the year is the same, but I think its not likely for an event to go for an entire year (so the months would be different anyway). The only thing that would be missing is the first year for an even that spans the end of the year. But I can live with that.
Sep 18, 2008
Kurund Jalmi
If you are using Drupal 5.x
Change:
$display .= l($title_place.' '.$title_desc, 'civicrm/event/info', array( 'query' => 'reset=1&id='.$event'id' )).'<br />';
to:
$display .= l($title_place.' '.$title_desc, 'civicrm/event/info', array(), 'reset=1&id='.$event'id').'<br />';
Oct 30, 2008
Andres Spagarino
Where is this file for the Joomla crowd?
Oct 30, 2008
Andres Spagarino
Boy... I should look at the source code before posting...
Dec 03, 2008
Trevor James
I'm trying to get this to work with Drupal 6.6 and CiviCRM 2.1.2. The display of events outputs but the links don't work. I'm getting the following URL for all events:
http://sites.fcps.org/inservice/civicrm/event/info
It's duping it for each event and not sticking the event ID in. How can I fix this?
-backdrifting
Dec 04, 2008
David Greenberg
Please repost to forums - that's a better place to get help debugging stuff.