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 CiviEvents PHP Block "could not find valid value for id"
Pages: [1]

Author Topic: Upcoming CiviEvents PHP Block "could not find valid value for id"  (Read 1107 times)

csialbany

  • Guest
Upcoming CiviEvents PHP Block "could not find valid value for id"
September 25, 2009, 06:56:17 am
Hi all,

For upcoming events I have the following php code in a drupal block:

Code: [Select]
<?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';
  
// 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,'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;
// 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.';
  }
}
?>

The block shows up with links to the events but when you click the the link a page is returned reading:

"Sorry. A non-recoverable error has occurred.

Could not find valid value for id"

Any help is greatly appreciated.

Donald Lobo

  • Administrator
  • I’m (like) Lobo ;)
  • *****
  • Posts: 15963
  • Karma: 470
    • CiviCRM site
  • CiviCRM version: 4.2+
  • CMS version: Drupal 7, Joomla 2.5+
  • MySQL version: 5.5.x
  • PHP version: 5.4.x
Re: Upcoming CiviEvents PHP Block "could not find valid value for id"
September 25, 2009, 10:29:20 am

seems like there is something wrong with the php code. What is the specific url that you click on that gives you the error?

i suspect it does not have the id value as part of the url

lobo
A new CiviCRM Q&A resource needs YOUR help to get started. Visit our StackExchange proposed site, sign up and vote on 5 questions

kmitz

  • I post occasionally
  • **
  • Posts: 74
  • Karma: 2
Re: Upcoming CiviEvents PHP Block "could not find valid value for id"
September 28, 2009, 07:14:18 pm
Check the last couple posts of this forum entry.

http://forum.civicrm.org/index.php/topic,2971.0.html

csialbany

  • Guest
Re: Upcoming CiviEvents PHP Block "could not find valid value for id"
September 29, 2009, 06:11:45 am
Thank you for your help,

donald lobo's post at http://forum.civicrm.org/index.php/topic,2971.0.html fixed the problem. The exact fix was:

"[the script is] confliciting with another function in some drupal module called cmp_date. Just rename the function to eventpage_cmp_date and search for cmp_date in that file (it should appear at least once more, line 71) and rename it there too"

Pages: [1]
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Support »
  • Using CiviCRM »
  • Using CiviEvent (Moderator: Yashodha Chaku) »
  • Upcoming CiviEvents PHP Block "could not find valid value for id"

This forum was archived on 2017-11-26.