I am trying to display the locality field in my custom node.tpl.php.

Normally something like print $node->field_location2['0']['value']['address']['locality'] would get the job done for normal cck fields but this is not the case with the locality field.

So does anyone know how i would go about printing the locality in my node.tpl.php?

Muchoz thanks!

Comments

GolDRoger’s picture

Installed today and had the same need. This is how i did it:

my filed is called location

<?php print $node->field_location['0']['value']->address->locality; ?>
<?php print $node->field_location['0']['value']->address->postalcode; ?>
<?php print $node->field_location['0']['value']->address->thoroughfare; ?>
<?php print $node->field_location['0']['value']->address->search; ?>

This will exatly print out what you need. If you need other fields just use this

<?php print_r($node->field_location); ?>

This will print out the array with all values you can use, just check what you need and change the last part (locality, postalcode, ...)

Hope it helps.

Luke