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) »
  • Public CiviEvents no longer show up in Calendar or through PHP Script
Pages: [1]

Author Topic: Public CiviEvents no longer show up in Calendar or through PHP Script  (Read 919 times)

csialbany

  • Guest
Public CiviEvents no longer show up in Calendar or through PHP Script
March 16, 2010, 05:25:16 pm
Hi all,

I have been administering CiviEvent on a drupal-based website for about 4 or 5 months. When "public event" is checked the events have shown up on our calendar without a problem. They are also displayed on the front page using the script at the end of this post.

This week new events suddenly stopped appearing on the calender or through the script. The events which had previously posted still appear, just no new events. No changes were made to the site to my knowledge, and I have created several test events with no luck. Caching is disabled, and I have attempted to clear the cache. I believe I have checked the "obvious" such as: Do I have the correct start and end dates for the events? Do I have public event checked?

Any help is greatly appreciated,
Graham


Code: [Select]
<?php

function eventpage_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';
  
// This example limits listing to public and active events
  
$params = array ('is_public'     => 1, 'is_active'     => 1);
  
$myEvents = civicrm_event_search( $params );
  if (
$myEvents) {
    
$count = 0;
    
$last = '';
    
usort($myEvents,'eventpage_cmp_date');
    foreach (
$myEvents as $event) {
      
$now = date('Y-m-d H:i:s');
      if (
$now > $event['end_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( 'query' => 'reset=1&id='.$event['id'] )).'<br />';
      echo 
$display;
      
$count++;
      
$last = $startdate;
      if (
$count > 8) break;
// this limits the number of events to 8 - put in whatever number suits you
    
}
    if (
$count > 0) {

    } else {
      echo 
'No events found.';
    }
  } else {
    echo 
'No events found.';
  }
}
?>

Dave Greenberg

  • Administrator
  • I’m (like) Lobo ;)
  • *****
  • Posts: 5760
  • Karma: 226
    • My CiviCRM Blog
Re: Public CiviEvents no longer show up in Calendar or through PHP Script
March 17, 2010, 12:04:39 pm
Pretty weird if nothing has really changed :-(

Best bet is to add debug code inline to the code below and see what $myEvents is returning. If that doesn't have your new events, you'll need to dig a bit further into the civcirm_event_search api.
Protect your investment in CiviCRM by  becoming a Member!

csialbany

  • Guest
Re: Public CiviEvents no longer show up in Calendar or through PHP Script
March 18, 2010, 09:09:06 am
Dave,

Thanks for the tip. I actually found that script on a site (can't find the link anymore unfortunately) and just tweaked it a tiny bit. I will do some research on script debugging, but do you have any quick instructions or advice on the debugging process?

Dave Greenberg

  • Administrator
  • I’m (like) Lobo ;)
  • *****
  • Posts: 5760
  • Karma: 226
    • My CiviCRM Blog
Re: Public CiviEvents no longer show up in Calendar or through PHP Script
March 18, 2010, 12:25:16 pm
You can insert CRM_Core_Error::debug('myEvents', $myEvents); to dump a given var to the screen (in this case, $myEvents).
Protect your investment in CiviCRM by  becoming a Member!

Pages: [1]
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Support »
  • Using CiviCRM »
  • Using CiviEvent (Moderator: Yashodha Chaku) »
  • Public CiviEvents no longer show up in Calendar or through PHP Script

This forum was archived on 2017-11-26.