I have thousands of nodes all geocoded using the location module. I had hoped that the meta tags module would recognize that a node had a location and output that location as the geoURL tag - but it doesn't. If a node already has a location set (using the location module) it seems kind of crazy to re-enter the value again in order to get a GeoURL tag output.

I've made the following hacks to my version of geourl.inc to do this for me. This hack is limited - it is hard coded such that the first location for a node is the one becomes the geoURL.

I'm posting here because I'm not a PHP or Drupal module developer and there are probably unforeseen consequences of this hack. I also don't know the meta tags module very well. Some other improvements I could think of include what do you do about multiple locations assigned to a module (can/how do you output more than one geoURL), how/can you output more than just the latitude & longitude (the Geo Tag Element allows for Place Name & Region). Does this break anything?

/**
 * @file
 * Support file for GEOURL meta tag.
 */

function nodewords_geourl_prepare($type, $ids, $value, $settings) {
  if ((!isset($value) || $value == '') && !($type == 'node' && variable_get('location_'. $type, 0) && module_exists('location'))) {
    $value = $settings['global']['geourl'];
  }
 
  if (module_exists('location') && ($type='node')) {
    $node = node_load($ids[0]);
    $value = (string)$node->locations[0]['latitude'].';'.(string)$node->locations[0]['longitude'];
  }
  return $value;
}

function nodewords_geourl_form($type, $value, $settings) {
  return array(
    '#type' => 'textfield',
    '#title' => t('GeoURL'),
    '#default_value' => $value,
    '#size' => 60,
    '#maxlength' => $settings['max_size'],
    '#description' => t('Enter a GeoURL (latitude, longitude) for this page.'),
  );
}

Comments

yhzsailor’s picture

Already found two problems. 1. things like admin menus etc get Meta Tags, so it was trying to output meta tags for things that didn't have node content and this generated lots of errors. 2. If a node didn't have a location already set, then Meta Tags were output which contained just a ";".

I'm not setup to check out/in code - It would be great if someone could take this suggestion, review it and merge it into the module.

Cleaned these errors up with this code:

function nodewords_geourl_prepare($type, $ids, $value, $settings) {
  if ((!isset($value) || $value == '') && !($type == 'node' && variable_get('location_'. $type, 0) && module_exists('location'))) {
    $value = $settings['global']['geourl'];
  }
  if (module_exists('location') && ($type='node')&& !is_null($ids[0])) {
    var_dump($ids);
    $node = node_load($ids[0]);
    if (isset($node->locations[0]['latitude'])) {
       $value = (string)$node->locations[0]['latitude'].';'.(string)$node->locations[0]['longitude'];
    }
    
  }

  return $value;
yhzsailor’s picture

Already found two problems. 1. things like admin menus etc get Meta Tags, so it was trying to output meta tags for things that didn't have node content and this generated lots of errors. 2. If a node didn't have a location already set, then Meta Tags were output which contained just a ";".

I'm not setup to check out/in code - It would be great if someone could take this suggestion, review it and merge it into the module.

Cleaned these errors up with this code:

function nodewords_geourl_prepare($type, $ids, $value, $settings) {
  if ((!isset($value) || $value == '') && !($type == 'node' && variable_get('location_'. $type, 0) && module_exists('location'))) {
    $value = $settings['global']['geourl'];
  }
  if (module_exists('location') && ($type='node')&& !is_null($ids[0])) {
    
    $node = node_load($ids[0]);
    if (isset($node->locations[0]['latitude'])) {
       $value = (string)$node->locations[0]['latitude'].';'.(string)$node->locations[0]['longitude'];
    }
    
  }

  return $value;
yhzsailor’s picture

Already found two problems. 1. things like admin menus etc get Meta Tags, so it was trying to output meta tags for things that didn't have node content and this generated lots of errors. 2. If a node didn't have a location already set, then Meta Tags were output which contained just a ";".

I'm not setup to check out/in code - It would be great if someone could take this suggestion, review it and merge it into the module.

Cleaned these errors up with this code:

function nodewords_geourl_prepare($type, $ids, $value, $settings) {
  if ((!isset($value) || $value == '') && !($type == 'node' && variable_get('location_'. $type, 0) && module_exists('location'))) {
    $value = $settings['global']['geourl'];
  }
  if (module_exists('location') && ($type='node')&& !is_null($ids[0])) {
    
    $node = node_load($ids[0]);
    if (isset($node->locations[0]['latitude'])) {
       $value = (string)$node->locations[0]['latitude'].';'.(string)$node->locations[0]['longitude'];
    }
    
  }

  return $value;
Marc Bijl’s picture

I'm starting a photo blog and it would be great to have location module data as meta tags:

- For search engine optimization
- For integration with web applications

Can anyone tell something about intentions and status?

Marc Bijl’s picture

Hmm, seems to do a nice job...

Working like a charm.
Would be great to have this implemented.

+1

smitty’s picture

Marked http://drupal.org/node/199281 as a duplicate of this issue.

SocialNicheGuru’s picture

subscribing

apaderno’s picture

Title: Use existing Node Location from Location module for GeoURL/ICBM Meta Tag » Use existing node location from location module for GeoURL/ICBM Meta Tag
Status: Active » Closed (won't fix)

As the Drupal 5 version is not supported anymore, I am changing the status of this report.

smitty’s picture

Version: 5.x-1.12 » 6.x-1.0
Status: Closed (won't fix) » Active

What's about this feature for D6?

apaderno’s picture

Version: 6.x-1.0 » 6.x-1.x-dev
Status: Active » Postponed

I changed the code of the development snapshot that was not actually using the location set by location.module.
The module now uses the location set by the module for the nodes; I will look for setting the location for the user profiles too.

I am setting the report to postponed, for the moment.

apaderno’s picture

Status: Postponed » Fixed

The feature request is for the node location; as the code to set the node location has been implemented / corrected, I will set the report to fixed.

If you would like the module to set the location also for the user profiles please open a new feature request.

SocialNicheGuru’s picture

does this also work for cck locations?

apaderno’s picture

It works only with the coordinates given by location.module, which are available in $node->locations (where $node is a node object loaded with node_load()).

It will be possible to use the content of any CCK fields to populate the meta tags content when the module uses the tokens handled by token.module. See #508496: Support for tokens to follow-up the progress of that feature.

apaderno’s picture

Issue tags: +6.x-1.0

I am setting the tags to trace the features added after version 6.x-1.0 has been created.

Status: Fixed » Closed (fixed)
Issue tags: -6.x-1.0

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