I have a resource directory with basic location info (street, additional, city, province, postal, country) plus the phone number. I can enter all this and it is preserved in the database (i.e. I can see it when I edit it again). However the phone number does not appear when I simply view the node. All other info is listed, even for multiple locations, just no phone number.

I'm sure it's something simple I've missed but I sure can't figure it out.

Another oddity is that when I "add another location" there are fields for everything EXCEPT the phone number. To add a phone number to an additional locaton I must edit the whole resource directory entry. entry. Is this related?

Help!

Comments

raymondllee’s picture

Having the same issue. Subscribing.

StephanieM’s picture

Knock knock??

TrevorG’s picture

Stephanie, I posted this here: http://drupal.org/node/209431 before realizing my request is essentially a clone.

However, there is an easy work around for your situation, which is to go into contemplate and do it for yourself. Unfortunately, as I stated in my post, there is no way to make it really pretty, the phone number will appear by itself.

The exact line you will need to insert will be print $node->location['phone']

mandclu’s picture

I was able to resolve this by adding the following lines above line 180 of location.theme:

    if(!empty($location['phone']) && !in_array('phone', $hide)) {
      $output .=  '<div class="phone">'. $location['phone'] .'</div>';
    }

So, the new version of theme_location in its entirety would be:

function theme_location($location = array(), $hide = array()) {
  if (_location_nothing_to_show($location, $hide)) {
    return '';
  }

  $output = '';
  if (isset($location['country']) && ($f = theme_get_function('location_'. $location['country']))) {
    $output .= call_user_func($f, $location, $hide);
  }
  elseif (count($location)) {
    $output .= "\n";
    $output .= '<div class="location vcard"><div class="adr">'."\n";
    if (!empty($location['name']) && !in_array('name', $hide)) {
       $output .= '<div class="fn">'. $location['name'] .'</div>';
    }

    if (!empty($location['street']) && !in_array('street', $hide)) {
      $output .= '<div class="street-address">'. $location['street'];
      if (!empty($location['additional']) && !in_array('street', $hide)) {
        $output .= ' ' . $location['additional'];
      }
      $output .='</div>';
    }

    if (!empty($location['city']) && !in_array('city', $hide)) {
      $city_province_postal[] = $location['city'];
    }

    if ((!empty($location['city']) && !in_array('city', $hide)) ||
        (!empty($location['province']) && !in_array('province', $hide)) ||
        (!empty($location['postal_codet']) && !in_array('postal_code', $hide))) {

      $city_province_postal = array();

      if (!empty($location['city']) && !in_array('city', $hide)) {
        $city_province_postal[] = '<span class="locality">'. $location['city'] .'</span>';
      }

      if (!empty($location['province']) && !in_array('province', $hide)) {
        $city_province_postal[] = '<span class="region">'. $location['province'] .'</span>';
      }

      if (!empty($location['postal_code']) && !in_array('postal_code', $hide)) {
        $city_province_postal[] = '<span class="postal-code">'. $location['postal_code'] .'</span>';
      }

      $output .= implode(', ', $city_province_postal);
    }

    if (!empty($location['country']) && !in_array('country', $hide)) {
      $countries = _location_get_iso3166_list();
      $output .= '<div class="country-name">'. t($countries[$location['country']]) .'</div>';
    }

    if (isset($location['latitude']) && isset($location['longitude'])) {
      $output .=  '<div class="geo"><abbr class="latitude" title="'. $location['latitude'] .'" /><abbr class="longitude" title="'. $location['latitude'] .'" /></div>';
    }
    if(!empty($location['phone']) && !in_array('phone', $hide)) {
      $output .=  '<div class="phone">'. $location['phone'] .'</div>';
    }

    $output .= '</div></div>';
  }

  $output .= location_map_link($location);

  return $output;
}
TrevorG’s picture

This worked very well, thank you surge!

I assume you would do something similar for fax?

Also, if we add the fax output can we add a label for each, ie. "Phone:" and "Fax:" ? If so, I believe this should be submitted as a patch because it is really a bug that it doesnt include these fields in the output by default.

StephanieM’s picture

Looks good, folks - thanks!

However I still have the problem when I "add another location" of not getting a new phone number field. I still have to edit the whole entry in order to enter the second phone number.

Also, how do you delete a location?

bdragon’s picture

You can't at the moment. It's on my TODO for 3.0 though.

bdragon’s picture

Bobuido’s picture

In response to
#4 by surge_martin - January 21, 2008 - 16:13

I'm a bit lost on versions. I only recently noticed there were 2.X releases when I spotted you talking about 3! Then I found http://drupal.org/node/199282 . I figured you hadn't updated the project page because they weren't considered stable enough but now I see it was marked incorrectly.

So my questions are :)

Has this omission of the phone numbers been resolved?

If so - What version fixes this error? & Is it stable, or, should I edit manually?

I can use the Contemplate module to achieve the same thing right? Or better to manually edit location.theme?

Thanks everyone for your time

bdragon’s picture

Status: Active » Closed (duplicate)