klox7 VIP
Total posts: 914
23 Dec 2013 06:23

Can I echo just address from geo field in record? Or just city or country? Thanks

Last Modified: 02 Mar 2014


klox7 VIP
Total posts: 914
24 Dec 2013 03:14

Can I do something with $address?


Sergey
Total posts: 13,748
24 Dec 2013 05:11

Every address field has parameter to be displayed or not.


klox7 VIP
Total posts: 914
24 Dec 2013 16:27

Yes, but I want to display it in custom template without depending on geo field.


Sergey
Total posts: 13,748
24 Dec 2013 23:43

Just copy custom template and there is

$this->value['address']

Which is array of fields.

$this->value['address']['city']


klox7 VIP
Total posts: 914
25 Dec 2013 08:53

Inserted this in record template and it works except for company (Notice: Undefined index: company in...). And I guess you can write nicer code for this.


<?php echo $item->fields_by_id[geo_field_id]->value['address']['company']; echo $item->fields_by_id[geo_field_id]->value['address']['address1']; echo $item->fields_by_id[geo_field_id]->value['address']['zip']; echo $item->fields_by_id[geo_field_id]->value['address']['city']; echo $item->fields_by_id[geo_field_id]->value['address']['country']; ?>

Sergey
Total posts: 13,748
25 Dec 2013 08:57

Add @ to it to suppress notice.

echo @$item->fields_by_id[geo_field_id]->value['address']['company'];


Sergey
Total posts: 13,748
26 Dec 2013 01:05

try

var_dump($item->fields_by_id[geo_field_id]->value)

And see what is in there.


klox7 VIP
Total posts: 914
26 Dec 2013 05:28

I think ['company'] is OK but it somehow doesn't work. I checked with var_dump(get_object_vars($item->fields_by_id[id])); and I can see it. But with var_dump($item->fields_by_id[geo_field_id]->value) there is no value for company. With field results also everything is OK fields_by_id[deo_field_id]->result; ?>


Sergey
Total posts: 13,748
27 Dec 2013 00:36

Mistery :O


klox7 VIP
Total posts: 914
19 Jan 2014 09:09

How can I make this filterable in custom template (active link to all results with this value)?

echo $item->fields_by_id[geo_field_id]->value['address']['city'];


Sergey
Total posts: 13,748
19 Jan 2014 22:46

The address elements are not filterable as links even in core template. You cannot make them filterable. It will only be filterable in geo field filter.

Powered by Cobalt