Created
August 16, 2013 20:34
-
-
Save tarnus/6253311 to your computer and use it in GitHub Desktop.
custom formatter to include phone and fax using addressfield_phone
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$formatter = new stdClass(); | |
$formatter->disabled = FALSE; /* Edit this to true to make a default formatter disabled initially */ | |
$formatter->api_version = 2; | |
$formatter->name = 'my_address'; | |
$formatter->label = 'My Address'; | |
$formatter->description = ''; | |
$formatter->mode = 'php'; | |
$formatter->field_types = 'addressfield'; | |
$formatter->code = ' $address=""; | |
foreach ($variables[\'#items\'] as $item) { | |
$address.=\'<div class="office-item">\'; | |
if($item[\'organisation_name\']!=""){ | |
$address.=\'<div class="addressfield-container-inline name-block"><span class="organisation-name">\'.$item[\'organisation_name\'].\'</span></div>\'; | |
} | |
if($item[\'locality\']!=""){ | |
$city=$item[\'locality\'].\',\'; | |
}else{ | |
$city=""; | |
} | |
$address.=\'<div class="thoroughfare">\'.$item[\'thoroughfare\'].\' \'.$item[\'premise\'].\'</div>\'; | |
$address.=\'<div class="addressfield-container-inline locality-block"><span class="locality">\'.$city.\'</span> <span class="state">\'.$item[\'administrative_area\'].\'</span> <span class="postal-code">\'.$item[\'postal_code\'].\'</span></div>\'; | |
$address.=\'<div class="addressfield-container-inline phone-block"><span class="phone">\'.$item[\'phone_number\'].\'</span> <span class="fax">\'.$item[\'fax_number\'].\'</span></div>\'; | |
$address.=\'</div>\'; | |
} | |
$output=\'<div class="field field-name-field-offices field-type-addressfield field-label-hidden"><div class="field-items"><div class="field-item even">\'.$address.\'</div></div></div>\'; | |
return $output; | |
'; | |
$formatter->fapi = ''; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment