Google Latlng Lookup

ExpressionEngine 2

Back to this add-on's main page
View Other Add-ons From No Two The Same


You must be logged in to post.

Compatibility With ExpressionEngine Channel Entries API

Feature Request


Thanks for putting this field type out there. It’s very useful. I did, however, run into one problem with it.

At the moment, Google Latlng Lookup doesn’t work with the EE Channel Entries API. The reason for this is that the API calls the field’s save($data) method providing $data as a parameter. Since the save() method as written now overwrites the $data variable with data in the $_POST, the API will write the field into the database as a string with two pipes in it.

In order to make this field_type compatible with the Channel Entries API, you could modify the save() method as follows:

function save($data)
if ( $this->EE->input->post($this->prefix.'address') && $this->EE->input->post($this->prefix.'latitude') && $this->EE->input->post($this->prefix.'longitude') ) {
$this->EE->input->post($this->prefix.'address'TRUE) . '|' $this->EE->input->post($this->prefix.'latitude'TRUE) . '|' $this->EE->input->post($this->prefix.'longitude'TRUE);
return $data;

I have not had a chance to test this a whole lot, but wanted to know if you think this will break anything. If not, you may consider adding the conditional above if you want the Channel Entries API to play nicely with your field type.

Thank you.

Elliot Lewis
# 1
Elliot Lewis

Thanks for the post Sarcastron.

I have to say I haven’t written another AddOn that interacts with the Channel Entries API to insert new entries but theoretically Latlng Lookup should work fine. This fieldype saves it’s data as a pipe delimited string. So as long as you pass data in, in that format, to the correct field_id it should work OK.

$data = array(
'title'         => 'Breaking News Story!',
'entry_date'    => '1256953732',
'edit_date'     => '1351653729',
'field_id_6'    => 'OX41XF|51.7387981|-1.2207837999999356',
'field_ft_6'    => 'none',