CiviCRM Community Forums (archive)

*

News:

Have a question about CiviCRM?
Get it answered quickly at the new
CiviCRM Stack Exchange Q+A site

This forum was archived on 25 November 2017. Learn more.
How to get involved.
What to do if you think you've found a bug.



  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Support »
  • Using CiviCRM »
  • Using CiviEvent (Moderator: Yashodha Chaku) »
  • Upcoming event Block
Pages: [1]

Author Topic: Upcoming event Block  (Read 2157 times)

sharique

  • Guest
Upcoming event Block
July 27, 2007, 07:29:23 am
How I can create a Upcoming event Block in Drupal?

Michał Mach

  • Ask me questions
  • ****
  • Posts: 748
  • Karma: 59
    • CiviCRM site
  • CiviCRM version: latest
  • CMS version: Drupal and Joomla latest
  • MySQL version: numerous
  • PHP version: 5.3 and 5.2
Re: Upcoming event Block
July 27, 2007, 07:48:33 am
CiviCRM doesn't have this functionality by default. You could try playing with Drupal's Views module (specifically calendar view), although I'm not that sure it will let you do the block thing.

You could also take the iCal feed from CiviEvent, and either try to write some code that will format it into nice upcoming event block, or use rss feeds Drupal module to do this.

For hints on calendar module try searching this forum for "calendar" and "iCal" terms.

Thx,
m
Found this reply helpful? Contribute NOW and help us improve CiviCRM with the Make it Happen! initiative.

My absolute favourite: Wordpress Integration!.

Donate Now!

sharique

  • Guest
Re: Upcoming event Block
July 27, 2007, 06:34:26 pm
Views doesn't provide Civicrm event fields.

Michał Mach

  • Ask me questions
  • ****
  • Posts: 748
  • Karma: 59
    • CiviCRM site
  • CiviCRM version: latest
  • CMS version: Drupal and Joomla latest
  • MySQL version: numerous
  • PHP version: 5.3 and 5.2
Re: Upcoming event Block
July 27, 2007, 07:06:13 pm
By "using Views" I meant grabbing iCal feed from CiviEvent, getting it into Calendar view and going with displaying upcoming events from there. This solution has been described here on forum, can also be seen on our demo site for Drupal. However, as said, no idea how to make it work with blocks.

Thx,
m
Found this reply helpful? Contribute NOW and help us improve CiviCRM with the Make it Happen! initiative.

My absolute favourite: Wordpress Integration!.

Donate Now!

jeff porter

  • I post occasionally
  • **
  • Posts: 72
  • Karma: 2
CiviEvent: Upcoming event Block
September 02, 2007, 10:18:27 pm
Here is the code from the block we created for our site (www.fpwr.org).  Modify as needed for your site:

<?php

function cmp_date($a,$b) {
  if ($a['start_date'] > $b['start_date']) return 1;
  if ($a['start_date'] < $b['start_date']) return -1;
  return 0;
}

if (module_exists('civicrm')) {
  civicrm_initialize(TRUE);
  require_once 'api/v2/Event.php';
  $params = array ();
  $myEvents = civicrm_event_search( $params );
  if ($myEvents) {
    $count = 0;
    $last = '';
    usort($myEvents,'cmp_date');
    foreach ($myEvents as $event) {
      $now = date('Y-m-d H:i:s');
      if ($now > $event['start_date']) continue;
      $startdate = date('D M j Y',strtotime($event['start_date']));
      $enddate = date('D M j Y',strtotime($event['end_date']));
             
      $eventid = $event['id'];
      list($title_place, $title_desc) = split(":",$event['title'],2);
      if ($last != $startdate) {
        $display = '<br /><b>'.$startdate.'</b><br />';
      }
      $display .= l($title_place.' '.$title_desc, 'civicrm/event/info', array(), 'reset=1&id='.$event['id']).'<br />';
      echo $display;
      $count++;
      $last = $startdate;
      if ($count > 8) break;
    }
    if ($count > 0) {
//      echo '</ol>';
    } else {
      echo 'No events found.';
    }
  } else {
    echo 'No events found.';
  }
}
?>
Jeff Porter
Foundation for Prader-Willi Research (www.fpwr.org)

Pages: [1]
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Support »
  • Using CiviCRM »
  • Using CiviEvent (Moderator: Yashodha Chaku) »
  • Upcoming event Block

This forum was archived on 2017-11-26.