Thread tagged as: Question

problem joining content from events with content...

If you see something obvious here I would appreciate it...

I'm trying to join the venue information ($venue_array)) to the event data $event_array) and then display it with perch_template...

I'm trying to grab the venue info for display as shown below... It's weird... it works for every item except the first one... So I must be making a php mistake, but I can't see it.

Here's the relevant code:

// end get venue info

    $today = date('Y-m-d');
    $tomorrow = date('Y-m-d', strtotime('tomorrow'));
    $dayaftertomorrow = date("Y-m-d", strtotime("+2 day"));
    PerchSystem::set_var('today', $today);
    PerchSystem::set_var('tomorrow', $tomorrow);
    PerchSystem::set_var('dayaftertomorrow', $dayaftertomorrow);

        $opts = array(

                'filter'   => 'eventDateTime',
                'match'    => 'gte',
                'value' => date('Y-m-d'),
                'category' => array('mic-the-robot'),

            $eventarray =   perch_events_custom($opts);

for ($i=0;$i<count($eventarray);$i++)

            $start = $eventarray[$i]['eventDateTime'];
            $venue = $eventarray[$i]['event_venue'];

            $venue_array = perch_content_custom('Venue', array('skip-template'=>true, 'filter'=>'venue-slug', 'match'=>'eq', 'value'=> $venue, 'page'=>'/venue.php'),true);

            $venue_name = $venue_array[0]['venue'];

            $address = $venue_array[0]['address'];

            $map = $venue_array[0]['map'];

            $displayDate = strtotime($start);
            $event = $eventarray[$i]['eventTitle'];
            $description = $eventarray[$i]['eventDescHTML'];
            $datedescription = '<p><strong class="date">'.date('l, F d, Y g:ia',$displayDate).'</strong> '.substr($description, 3);
            $duration = $eventarray[$i]['program_duration'];
            $duration_hour = floor($duration);
            $duration_minute = round(60*($duration-$duration_hour));
            $tz = new DateTimeZone('America/New_York');
            $dateend = new DateTime($start);
            $start_minute = $dateend->format('i');
            $dateend->modify('+'.$duration_hour.' hours +'.$duration_minute.' minutes');
            $endtime = $dateend->format('g:i a');
            $end_minute = $dateend->format('i');

            $endtimeadd = $dateend->format('Y-m-d h:i:s A');
            if (empty($duration)) {
                $endtime = $dateend->modify('+ 2 hours');
                $endtime = $dateend->format('g:i a');
                $endtimeadd = $dateend->format('Y-m-d h:i:s A');
            $eventarray[$i]['endtimeadd'] = $endtimeadd;  
            $eventarray[$i]['endtime'] = $endtime;
            $eventarray[$i]['startminute'] = $start_minute;
            $eventarray[$i]['datedescription'] = $datedescription;
            $eventarray[$i]['endminute'] = $end_minute;
            $eventarray[$i]['venue_name'] = $venue_name;
            $eventarray[$i]['address'] = $address;
            $eventarray[$i]['map'] = $map;


perch_template('content/_band_dates', $eventarray);

Thank you!

Monty Lewis

Monty Lewis 2 points

  • 4 years ago
Drew McLellan

Drew McLellan 2638 points
Perch Support

What happens with the first item?

No result is returned from the $venue_array

Drew McLellan

Drew McLellan 2638 points
Perch Support

Ok. That very much looks like either a data issue or a logic issue in your code. If your debugging points to it being related to Perch, let us know what you've got and we can look into it.

oh, I'm sure you're right. I was hoping someone who knows PHP better than me would notice an obvious mistake... :)


Drew McLellan

Drew McLellan 2638 points
Perch Support

I wish I had time to do free PHP consultancy for everyone, but sadly not.

I understand. I'll post a note in the slack group.