How would I go about changing the titles of location_cck fields?
i.e. I'm using the 'City' field in my nodes, but would instead like it to be called 'Area' when users enter data into it... Is this possible?

Comments

yesct’s picture

Issue tags: +Location theming

hmmm. Theme or form_alter?

try looking at issues tagged with:
location theming
or
location theme edit form

rooby’s picture

Status: Active » Fixed

Note that this code is created for the 3.1 version or current dev.

The location module provides a hook for this, called hook_locationapi(&$obj, $op, $a3 = NULL, $a4 = NULL, $a5 = NULL)
The field_expand $op is where locations fields are created and you can use that to modify the different fields of a location.

Here is an example that sets the title of the city field to Area:

<?php
/**
 * Implementation of hook_locationapi().
 */
function token_locationapi(&$obj, $op, $a3 = NULL, $a4 = NULL, $a5 = NULL) {
  switch ($op) {
    case 'field_expand':
      // For the field_expand $op, $a3 is the field name.
      switch ($a3) {
        case 'city':
          // This will be array_merged in with the field definition.
          return array(
            '#title' => t('Area'),
          );
      }
      break;
  }
}
?>

You need to create a custom module and add this hook.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

bedot’s picture

use string override module

trackleft’s picture

This does not work in Drupal 7 unless I am missing something

function chris_locationapi(&$obj, $op, $a3=NULL, $a4 = NULL, $a5 = NULL) {
  switch ($op) {
    case 'field_expand':
      // For the field_expand $op, $a3 is the field name.
      switch ($a3) {
        case 'name':
          // This will be array_merged in with the field definition.
          return array(
            '#title' => t('Building Name'),
            '#description' => 'If you know the name of the building, enter it here.',
          );
      }
	 case 'additional':
          // This will be array_merged in with the field definition.
          return array(
            '#title' => t('Room Number'),
            '#description' => 'If you know the room number, enter it here.',
          );
	case 'street':
         // This will be array_merged in with the field definition.
          return array(
            '#title' => t('Street Address'),
            '#description' => 'If you know the street address, enter it here.',
          );
      break;
  }
}
boblesurfeur’s picture

have you checked the Weight of your module ?

Mine begins with an F so it is executed before the module location.

Thanks Rooby for the tip btw.