Drupal Location Module - Changing to Locative Information from a CCK Field

Recently I've had to do this.  I create a Drupal Content Type using the Location Module and GMAP Module,   I created a Location CCK field and started entering (or importing) location data into the field.

Afterward, I realized that I did not really want a CCK Location Field.  Instead, I wanted to set the Locative information on the configuration page of my content type.  I did NOT want to re-key my location information, and it turns out I didn't need to.  

When you key in Location data to a location CCK field, the Location data is stored in the Location table.  It is stored in the same place when you use locative information.  The only difference is the data that is stored in the Location_Instance table.  Instead of storing a reference to the for a CCK field in genid, it stores the node id in the nid and vid fields.      

I ran the following query to take the node id from the rightmost characters of the genid and use them for the node id, and blank out the genid.  Worked like a charm... 

UPDATE `location_instance`

SET `nid` = right(`genid`,3),

   `vid` = right(`genid`,3),

   `genid` = ''

Tags: 

About the Author:

Tom Sliker

President / CEO / Lead Consultant

Tom Sliker serves as the ringleader for the Broadstreet team and has managed to build a diverse, talented, multi-faceted team that has performed a wide range of projects.   With over 30 years of software development and integration experience, Tom brings a wealth of technical and business knowledge to his customers and his team.