Hello! I'm trying to create a computed field aggregating a text field (street name, number) and a taxonomy term (hierarchy).
This seems the only way to geocode an address in drupal , avoiding using the "location" module, that it doesen't really fit for countries like italy, for example..
I'm very new to drupal, so, i really have no clue on what to do...
I read somewere, that to output the value of the taxonomy , i will have first to get the id, then to convert the value into a readable name .
I would also like to show all the yeararchy level (ex : province - city etc). not just the latest term of the taxonomy.
Then , obviosly, adding the text field, into the same field..
Any suggestion on how to do these things, would be really appreciated!


dwalker51’s picture

trying to do the same....

I can get the computed field showing the street ( a text field) + the Region, Province, Comuna ( A hierachical taxonomy), however I then run into a problem with geocode, see: http://drupal.org/node/624800

To at least get you to where I am....

I have a computed field called dirrecion, In it:
I am just outputing the street (calle) and the first and third term in the taxonomy Hierarchy (Region, Comuna)
Computed Code (PHP)

$field_myterms = field_get_items($entity_type, $entity, 'field_procedencia_chile');
if (!empty($field_myterms)) {
  $term1 = taxonomy_term_load($field_myterms[0]['tid']);
  $term2 = taxonomy_term_load($field_myterms[1]['tid']);
  $term3 = taxonomy_term_load($field_myterms[2]['tid']);

$temp= array_pop(array_pop(field_get_items($entity_type, $entity, 'field_calle'))) . "," . drupal_clean_css_identifier($term3->name)  . "," . drupal_clean_css_identifier($term1->name);

$entity_field[0]['value'] = (string) $temp;

Display Code (PHP)

$display_output = $entity_field_item['value'];

This at least will output your text and taxonomy fields, geocoding it is another issue....Hope this helps....will maybe see about other solutions like addressfield

dwalker51’s picture

I decided due to deadlines to go with addressfield....but there seems to be some movement here with respect to geocoding computed fields http://drupal.org/node/1679926