/ Published in: PHP
Assumes that the record has a `name` field which represents the name of the location and always has a defined two character `country` field.
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
public function __get($key) { if($key == 'short_address') { // this is tricky b/c the map is international // if the location is US based then we want to display an identifier similiar to: St. Joe's in Downingtown PA // if the location is non-USA based (and either city or providence is not available) then we want to display: St. Joe's in Downingtown USA return $this->name.' in '.$this->city.' '.$this->providence. } else if($key == 'full_address') { // target format for US based addresses: // 300 Road Street // Town PA 19335 // target format for non-US based addresses // address1 // City Providence Postal Code Country // the trims handle edge cases when there is not enough information to propertly display an address if($this->country == 'US') { } else { return $this->address1."\n".$this->address2."\n".$this->city." ".$this->providence." ".$this->postal_code." ".$this->country; } } return parent::__get($key); }