Created
January 10, 2019 03:54
Revisions
-
evandonovan renamed this gist
Jan 10, 2019 . 1 changed file with 1 addition and 0 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -1,5 +1,6 @@ // Override addressfield_tokens themeing function // Requires addressfield_tokens module as well as addressfield // Add to template.php and change THEMENAME to name of your theme, then clear cache function THEMENAME_addressfield_formatter__components($vars) { $loc = $vars['address']; $out = ''; -
evandonovan created this gist
Jan 10, 2019 .There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,42 @@ // Override addressfield_tokens themeing function // Requires addressfield_tokens module as well as addressfield function THEMENAME_addressfield_formatter__components($vars) { $loc = $vars['address']; $out = ''; // Note added RDFa microdata - https://schema.org/PostalAddress // Organization name if present (nothing in first or last name fields) if (!empty($loc['organisation_name']) && $vars['organisation_name']) { $out = '<span property="name" class="organization-name">' . $loc['organisation_name'] . '</span><br/>'; } // Street and additional on one line (no space), then break if (!empty($loc['thoroughfare'])) { $out .= '<span property="streetAddress" class="street">' . $loc['thoroughfare'] . '</span>'; // Add additional to line only if present (TODO: PO Box?) if (!empty($loc['premise']) && $vars['premise']) { $out .= '<span class="additional">' . $loc['premise'] . '</span>'; } $out .= '</br>'; } // City, state ZIP if (!empty($loc['locality'])) { $out .= '<span property="addressLocality" class="city">' . $loc['locality'] . "</span>, "; } if (!empty($loc['administrative_area'])) { $out .= '<span property="addressRegion" class="state-province">' . $loc['administrative_area'] . '</span>'; } if (!empty($loc['postal_code'])) { $out .= ' <span property="postalCode" class="postal-code">' . $loc['postal_code'] . '</span><br/>'; } // Country, if not US - see l. 121 of addressfield_tokens.theme.inc if(!empty($loc['country']) && $loc['country'] != 'us') { $out .= '<span property="addressCountry" class="country">' . _addressfield_tokens_country($loc['country']); } $output = '<span vocab="http://Schema.org" typeof="PostalAddress" class="addressfield">' . $out . '</span>'; return $output; }