Hi, I'm trying to clone a map and it's associated views.

Usually I will go to
$items['admin/structure/openlayers/maps/list/%ctools_export_ui/clone']
and try to find code in this kind of page callback. But in this case, I can't find it anywhere. I suppose it has used ctools' feature to build this menu item in openlayers_maps_ui.class.php?

So, get back to the question, how can I clone a map in code just as what page $items['admin/structure/openlayers/maps/list/%ctools_export_ui/clone'] has done? Or where can I find the page callback for this clone page? Thanks in advance!

Comments

ohthehugemanatee’s picture

Have a look at lines 780-819 of openlayers.module to find the relevant functions. the map's machine name is the unique key, so as long as you change that value it will be saved as a new map.

$newmap = openlayers_map_load('old_map_name');
$newmap->name = 'new_map_name';
$result = openlayers_map_save($newmap);
smiletrl’s picture

Thanks!