Well, forgive me if this was answered, but in the 12 hours of debug and frenzied Googeling, my problem was not apparent on any forum. I am new to Drupal, but come from a programmers background using ColdFusion and PHP. I have about 4 weeks experience and have a firm grasp on core concepts.
Anyway.
I followed 3 different tutorials in order to implement Location + Location CCK + Gmap. I tried each patch in several forum threads, used the stables releases and the RC releases. My problem was consistent across each. I even used the CVS releases from just days ago. Nothing actually fixed what I was experiencing...
So, I will 'in a nutshell' describe my methods... which can be further explained at this wonderful tutorial : http://www.drupaltherapy.com/gmap
My current Drupal set up involved a fresh install and a manual migration of 25M nodes. These nodes could be broken down into several CCK types, but the relevant ones are
Region (1) => (M) subregion (1) => (M) Areas (1) => (M) Buildings (1) => (M) Apartments (1) => (M) Listings.
I needed to Polygon Geo code the Region, Subregion and Areas. Further, I wanted to pinpoint the building with the option to have many addresses for a building, which is possible in some areas. I have not attempted the polygons yet, I figured the building pinpoints would be cake based upon the tutorial. I was wrong.
Problem: Followed the tutorial to a tee. The enabled Location Map block DID NOT appear on my node. Oddly, it appeared when I 'edited' a node, and when I had devel load and devel render on. The Block_view function was NOT being called for some reason on my view.
I tried :
<?php
$block = module_invoke('gmap_location', 'block', 'view', 0);
print $block['content']; ?>
and
<?php
$lat = $location[latitude];
$lon = $location[longitude];
print gmap_simple_map($lat,$lon,'','Hello World!','14','700px','500px','');
?>
Both worked beautifully, but they were in my template file and seemed 'hackish' to me. I wanted my block to work damn it!
So, I went to my database to look at location and location_instance. I quickly realized that location was being populated, and location_instance was as well -- BUT the VID was not being populated... and with devel I realized that it was joining on the VID...
location_load_location
SELECT * FROM Main_location WHERE lid = 3
location_load_locations
SELECT lid FROM Main_location_instance WHERE vid = 3
Now, why we do it twice? I have not figured this out yet. I figure I can help optimize this process? Unless my install is a 1 off.. but with the amount of complaints I saw about the block not appearing... I think this may be a bigger issue. People usually settle for the patches and views hacks... Not me.
Anyway, my solution was to populate the VID. SO i modified location_cck.module.
Line 177 is:
<?php
case 'update':
// Store instances of locations by field name and vid.
$genid = 'cck:'. $field['field_name'] .':'. $node->vid;
location_save_locations($items, array('genid' => $genid,);
// CCK automatically picks up the new lids and stores them in its own tables.
break;
// SHOULD BE: location_save_locations($items, array('genid' => $genid,'vid' => $node->vid);
?>
Or I could be a complete idiot? But everything works exactly like the tutorial advertised now. If anyone has a problem with the block displaying, try this and let me know how you fair ?
Comments
Comment #1
notsoluckycharm commentedGot it.
This tutorial works fine for 'NEW' Create content..
Steps to reproduce my problem?
1) Follow the tutorial, Set everything up.
2) Create a node with a location. It should work.
3) Create a node WITHOUT a location.
4) Edit the node without a location to add a location. Save
5) updates EVERYTHING except the VID.
Bingo. There we go. Did it on a fresh site. Since I already imported the ndoes, that's why it wasn't working until I forced the VIDs.
Comment #2
ankur commented