Use existing node location from location module for GeoURL/ICBM Meta Tag

yhzsailor - January 6, 2009 - 01:43
Project:Nodewords
Version:6.x-1.x-dev
Component:Code
Category:feature request
Priority:normal
Assigned:Unassigned
Status:closed
Issue tags:6.x-1.0
Description

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.'),
  );
}

#1

yhzsailor - January 6, 2009 - 02:21

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;

#2

yhzsailor - January 6, 2009 - 02:21

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;

#3

yhzsailor - January 6, 2009 - 02:21

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;

#4

New Oceans - January 15, 2009 - 16:38

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?

#5

New Oceans - January 15, 2009 - 21:48

Hmm, seems to do a nice job...

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

+1

#6

smitty - February 4, 2009 - 16:33

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

#7

SocialNicheGuru - June 7, 2009 - 13:39

subscribing

#8

kiamlaluno - July 2, 2009 - 16:05
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» won't fix

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

#9

smitty - July 3, 2009 - 11:18
Version:5.x-1.12» 6.x-1.0
Status:won't fix» active

What's about this feature for D6?

#10

kiamlaluno - July 3, 2009 - 17:01
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.

#11

kiamlaluno - July 3, 2009 - 17:07
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.

#12

SocialNicheGuru - July 4, 2009 - 04:27

does this also work for cck locations?

#13

kiamlaluno - July 4, 2009 - 05:49

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.

#14

kiamlaluno - July 5, 2009 - 00:44

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

#15

System Message - July 19, 2009 - 00:50
Status:fixed» closed

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

 
 

Drupal is a registered trademark of Dries Buytaert.