29th May 2015

Expression Engine Update Function

Expression Engine Update Function
This php code gets an item with the same URL title, if one exists then it updates it in expression engine.
<?php
ee()->load->library('api');
ee()->api->instantiate('channel_entries');
ee()->api->instantiate('channel_fields');
ee()->api->instantiate('channel_categories');

$title = 'your title';
$friendlyUrl = 'your friendly url';

$query = ee()->db->get_where('channel_titles', array('url_title' => $friendlyUrl), 1);
if($query->num_rows() > 0)

$row = $query->row(); $entry_id = $row->entry_id; if ($entry_id != FALSE)

$data = array( // set your values, see below for an example 'title' => $title ); ee()->api_channel_fields->setup_entry_settings(1, $data); if (ee()->api_channel_entries->save_entry($data, 1, $entry_id) === FALSE)

echo 'Error';

else

echo "Success";

?>
This website uses cookies to provide the best possible experience. By continuing to use our website you are agreeing to our use of cookies.