0
votes

I have a custom content type called "stores" with four fields (Address, Name, Lat, Lon)

I have multiple stores with the same name (ie: safeway) and when working in any part of the admin interface I see duplicates of "safeway" -- I would like to add a hook to essentially concatenate "Name" and "Address" so the safeways are disambiguated in all lists, etc:

Safeway (299 River Ave.)

or

Name (Address)

Can someone please point me in the right direction??? Which hook methods do I need to read about?

Are there templates I can override? Ideally I do this as a single hook as I cannot imagine a single place in the application where the address would not be beneficial .

EDIT | I have found the Field API here but I am unsure as to which hook to override:

https://api.drupal.org/api/drupal/modules%21field%21field.module/group/field/7

EDIT 2 | I think I have narrowed down my search to this API:

https://api.drupal.org/api/drupal/modules!field!field.api.php/function/hook_field_formatter_prepare_view/7

But a working example would sure help???

Alex

1

1 Answers

0
votes

I assume here that you are using the node's Title field as the Name field of your content type, becasue you say that you see duplicates in the admin interface.

If you need that just for administer your content, you can use the views module and build a view to show a page similar to admin/content that also shows the address field.

If you need the address to be also shown in the node page, you may use in the template.php file for your theme something like

function <yourtheme>_preprocess_node(&$variables, $hook) {
  if ($variables['node']->type == '<store_node_type>') {
    $variables['node']->title = $variables['node']->title . " ({$variables['node']->field_address})";
  }
}