All Low add-ons are now owned by EEHarbor. Read the blog post.

Support archive

low events import/migration script

timjukes 4 Aug 2012 19:13 question, complete

Hi - just been playing around with Low Events and looks great so far!

I'm trying to migrate some existing channel entries using a custom script - all seems to be working well, but I'm seeing a PHP notification error when looping through the {exp:low_events:entries} tag on the front end - it's saying:



A PHP Error was encountered

Severity: Notice

Message: Undefined index: end_time

Filename: low_events/ft.low_events.php

Line Number: 400



and the same for start_time and start_date.

The following is the script I'm using (it's a standalone Codeigniter script) - the custom fields I'm drawing from are saved as Unix timestamps. Like I say, the import all seems to be fine, but I'd like to work out what's causing the PHP errors. Maybe there's another table I should be adding data to?


$this->db->where('channel_id', 1);
$query = $this->db->get('exp_channel_data');
if ($query->num_rows() > 0)
{
foreach ($query->result() as $row)
{
$entry_date = false;
$expiration_date = false;
$entry_date = $row->field_id_1;
$expiration_date = $row->field_id_2;

if($expiration_date == 0){
$expiration_date = $entry_date;
}

$entry_date = date("Y-m-d", $entry_date);
$expiration_date = date("Y-m-d", $expiration_date);

$data = array(
'site_id' => '1' ,
'entry_id' => $row->entry_id,
'field_id' => '29',
'start_date' => $entry_date,
'end_date' => $expiration_date,
'start_time' => NULL,
'end_time' => NULL,
'all_day' => 'y'
);

$this->db->insert('exp_low_events', $data);

$data = array(
'field_id_29' => '{"start_date":"'.$entry_date.'","start_time":null,"end_time":null,"end_date":"'.$expiration_date.'","all_day":"y"}'
);
$this->db->where('entry_id', $row->entry_id);
$this->db->update('exp_channel_data', $data);

}
}

Replies

  1. timjukes 4 Aug 2012 19:15

    Oh - and also tried


    $jsonarr = array('start_date' => $entry_date, 'start_time' => null, 'end_time' => null, 'end_date' => $expiration_date, 'all_day' => 'y');

    $data = array(
    'field_id_29' => json_encode($jsonarr)
    );
    $this->db->where('entry_id', $row->entry_id);
    $this->db->update('exp_channel_data', $data);


    In case there was a problem passing the info as a string.

    I'm on EE 2.5.2 and Low Events 1.0.3

    I've got two separate channels using separate low_events fields and data appears to be in all of them, except start and end times which are NULL.

    Thanks!

  2. Low 5 Aug 2012 09:55

    I think the JSON is not being encoded/decoded properly. Try and load the JavaScript library and using its generate_json() method. It's what I use in the add-on.

  3. timjukes 5 Aug 2012 12:54

    Thanks for that - I think I was calling the wrong low events field in {if exhibition_dates:one_day} - all working fine now!

    Cheers!