So I only want this block to show up on pages that have a Latitude and Longetude and have tried lots of different things and none seem to work even using Variables out of the Module itself. Can anyone steer me in the right direction?? I have searched high and low on drupal and can find no one with this problem.

Here is what I'm currently have in my Block Visibility and doesn't work, I also Tried $location from another post I found about something not really related.

<?
global $map;
if ( ($map['latitude'] != 0) && ($location['longitude'] != 0) )
return TRUE;
}else {
return FALSE;
}
?>

Comments

davidhk’s picture

Category: support » bug

I've changed this to be a bug, as in the D5 version it only appeared on nodes that had a lat/lon set. (I've just uploaded from the D5 to D6 version of GMap, and run into this same problem).

I also had a go at writing some workaround php to paste into the block's visibility settings:

$match = FALSE;
if (arg(0) == 'node' && is_numeric(arg(1))) {
  if ($node = node_load(arg(1)) {
    if ( ($node->location['latitude'] != 0.0) && ($node->location['longitude'] != 0.0) ) {
      $match=TRUE;
    }
  }
}
return $match;

But mine doesn't work either! Has anyone else got a workaround?

davidhk’s picture

Here's a fix to the code that is working for me.

Edit file gmap_location.module, and look for function gmap_location_block_view($nid).

Scroll down to line
if ($loc['latitude'] || $loc['longitude']) {

and change it to
if (($loc['latitude'] != 0) || ($loc['longitude'] != 0)) {

The original version of this line also appears in the Drupal 5 version, so I'm not sure why it works there but not here.

AtomicStudios’s picture

Thanks!!!

rooby’s picture

Title: Gmap Location Block Visibility » Add a setting to hide location block if there are no locations
Version: 6.x-1.0 » 6.x-1.x-dev
Category: bug » feature

The same code as mentioned in #2 is still in the latest version so this still applies.

The question is whether or not to change the functionality now that potentially a lot of sites have the current functionality.

It would probably be better off as a block setting to choose what happens when there are no locations.