Closed (fixed)
Project:
Location
Version:
6.x-3.1-rc1
Component:
Documentation
Priority:
Normal
Category:
Support request
Assigned:
Unassigned
Reporter:
Created:
7 Sep 2009 at 18:28 UTC
Updated:
5 Feb 2011 at 01:00 UTC
I have some nodes that are have CCK text fields for users to enter their location information (cck text field for street, cck text field for city, cck text field for state, cck text field for zip). I want to use the Location module now. Is there a way I can "convert" the text CCK fields into Location CCK fields?
Comments
Comment #1
rooby commentedThere is no automated conversion in the location module. You would probably have to write a script that manually makes the change.
You could create the new location field.
Then write a script that gets the node ids of all the nodes you want to convert, then for each one it would:
* load the node
* Set $locations = array();
* create a location array for each location on the node (see the 'location' database table for the fields in the location array, or devel load a node that has a location on it or something)
* add the location to the $locations array,
* then when you have done all the locations for that node call location_save_locations($locations, array('nid' => $node->nid, 'vid' => $node->vid));
* then for cck data do something like:
* Then do a node_save.
That's basically it I think so with some tweaking you should be able to get it.
It isn't the most straightforward process though, it's not a simple requirement.
There might be some way of using some sort of drupal node export/import modules to export the node data to a csv and then back in from the csv to different fields. You would have to do some searching though as I'm not 100% sure what is out there that might work for such a thing.
The custom script would be the best way if you have coding skills or can afford to pay someone who does.
Comment #2
rooby commentedMarked #726400: importing data from (normal) cck fields for street address and city into location cck fields as duplicate of this issue.
Comment #3
rooby commented#740970: Migrate data from Addresses Module to Location CCK Module is a similar issue but it related to migrating from the address module instead of a regular cck field.
The approach used there is a little different but might be of use to people looking for more information.