Skip to end of metadata
Go to start of metadata
CiviCRM Documentation

This page refers to outdated version of CiviCRM. Check current version of documentation.

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 API

The 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

Subscribe to your CiviEvent Feed

Within a calendar application (such as Apple iCal), subscribe the the URL listed above and it will pull in the events from CiviEvent.

Labels
  • None
  1. Oct 08, 2007

    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:

  2. Oct 09, 2007

    Julia - Excellent addition to the code. I've updated it inline.

  3. Oct 19, 2007

    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:

  4. Nov 21, 2007

    How is this configuration of a block to support PHP code accomplished?

     Thanks,

    Ken 

    1. Jan 27, 2008

      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.

  5. Jan 27, 2008

    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. 

  6. Apr 17, 2008

    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 />';

  7. Apr 17, 2008

    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;

    1. Nov 04, 2008

      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.

  8. Sep 18, 2008

    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 />';

  9. Oct 30, 2008

    Where is this file for the Joomla crowd?

    1. Oct 30, 2008

      Boy... I should look at the source code before posting...(wink)


  10. Dec 03, 2008

    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

    1. Dec 04, 2008

      Please repost to forums - that's a better place to get help debugging stuff.


Creative Commons License
Except where otherwise noted, content on this site is licensed under a Creative Commons Attribution-Share Alike 3.0 United States Licence.