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 »
  • Upgrading CiviCRM (Moderator: Deepak Srivastava) »
  • Upgrade 3.1 to 3.4.5 Lost events list
Pages: [1]

Author Topic: Upgrade 3.1 to 3.4.5 Lost events list  (Read 744 times)

awasson

  • I post frequently
  • ***
  • Posts: 230
  • Karma: 7
  • Living in a world of Drupal / CiviCRM
    • My Company: Luna Design
  • CiviCRM version: Latest
  • CMS version: Drupal 6/7/8
  • MySQL version: 5.x
  • PHP version: 5.3.x
Upgrade 3.1 to 3.4.5 Lost events list
September 22, 2011, 10:14:33 am
Hello,
We upgraded our site from 3.1 to 3.4.5 and although everything else seems great we lost our event listing. It is in a Drupal block and worked up until shortly after the update. It may have been working until we cleared our cache and then it was gone. I can see all the events in the iCal feed so I know they are there, they just aren't available in our block.

Block code as follows:

Code: [Select]
<?php

// We use this function to sort the events in descending order by start date
// You can reverse the 1, -1 if you want it to sort in decending order
function civi_date_sorting($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;

    
// Call the sorting function
    
usort($myEvents,'civi_date_sorting');
    foreach (
$myEvents as $event) {
      
$now = time( );

      
// Need to format the event end date in unix time, so we call a CiviCRM helper function
      
$endDate = CRM_Utils_Date::unixTime( $event['end_date'] );

      
// We want to show any events whose end dates have not passed in case we have events that include ranges
      
if ( $now <= $endDate) {

        
// Now we format the event start and end dates again to be user-friendly, we are using month day, year format here
        
$startdate = date('M d, Y',strtotime($event['start_date']));
        
$enddate = date('M d, Y',strtotime($event['end_date']));

        
// if it's a date range, we need to show both start/end dates (7/1 - 7/10 for example); otherwise just show start (7/1)
        
if($startdate != $enddate){
          
$finaldate = $startdate." - ".$enddate;
        }
        else{
          
$finaldate = $startdate;
        }

        
$eventid = $event['id'];
        list(
$title_place, $title_desc) = split(":",$event['title'],2);

        
// We first display the dates, then add the title of the event and path to the registration page
        
$display = '<ul><li class="event"><span class="time">'.$finaldate.'</span><br />';


        
$display .= l($title_place.' '.$title_desc, 'civicrm/event/info', array('query' => 'reset=1&id='.$event['id']) ).'</li></ul>';

        
// Uncomment the line above and comment out the line below if you're using Drupal 6
        //$display .= l($title_place.' '.$title_desc, 'civicrm/event/info', array(), 'reset=1&id='.$event['id']).'</li></ul>';
        
echo $display;

        
// Increase the counter so we can know when to stop
        
$count++;

        
// Once we reach 6 events, stop
        
if ($count > 6) break;
      } 
// End if $now <= $endDate
    
} // End foreach
    
if ($count = 0) {
      echo 
'No events are currently scheduled.';
    }
  }
  else {
    echo 
'No events found.';
  }
} 
// End if CiviCRM exists

?>

My CiviCRM Extension Workshop: https://github.com/awasson

awasson

  • I post frequently
  • ***
  • Posts: 230
  • Karma: 7
  • Living in a world of Drupal / CiviCRM
    • My Company: Luna Design
  • CiviCRM version: Latest
  • CMS version: Drupal 6/7/8
  • MySQL version: 5.x
  • PHP version: 5.3.x
Re: Upgrade 3.1 to 3.4.5 Lost events list
September 22, 2011, 10:39:13 am
Update: I was just looking at my Events dashboard in civi and although my iCal feed will list out a ream of events my XML feed is empty. I should note that all of the upcoming events (4 of them) are public and active.
My CiviCRM Extension Workshop: https://github.com/awasson

Kurund Jalmi

  • Administrator
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4169
  • Karma: 128
    • CiviCRM
  • CiviCRM version: 4.x, future
  • CMS version: Drupal 7, Joomla 3.x
  • MySQL version: 5.5.x
  • PHP version: 5.4.x
Re: Upgrade 3.1 to 3.4.5 Lost events list
September 22, 2011, 01:14:00 pm
By default CiviCRM ships Upcoming Events block, have tried using it?

Kurund
Found this reply helpful? Support CiviCRM

awasson

  • I post frequently
  • ***
  • Posts: 230
  • Karma: 7
  • Living in a world of Drupal / CiviCRM
    • My Company: Luna Design
  • CiviCRM version: Latest
  • CMS version: Drupal 6/7/8
  • MySQL version: 5.x
  • PHP version: 5.3.x
Re: Upgrade 3.1 to 3.4.5 Lost events list
September 22, 2011, 02:27:10 pm
Yes,... should have mentioned that... The one that ships with civiCRM does not work either.

As an interim solution I have created a Drupal (CIVICRM_Event) View that contains all the necessary fields, filters, and ordering and then placed it as a block where the previous list was placed. That works exactly as we would like it to so it is a solution but I'm curious about where the disconnect is in the one that ships with civiCRM, the Events XML feed which is empty and the PHP coded block that worked at one point. 
My CiviCRM Extension Workshop: https://github.com/awasson

Pages: [1]
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Support »
  • Upgrading CiviCRM (Moderator: Deepak Srivastava) »
  • Upgrade 3.1 to 3.4.5 Lost events list

This forum was archived on 2017-11-26.