Closed (duplicate)
Project:
Location
Version:
6.x-3.0
Component:
Code
Priority:
Normal
Category:
Support request
Assigned:
Unassigned
Reporter:
Created:
4 Mar 2009 at 17:24 UTC
Updated:
16 Apr 2009 at 17:52 UTC
Hello,
we have implemented a simple way to reuse locations, and i want to make sure we're not duplicating something that is already in this module, or planning to be. If it's useful, please use the code.
we are gathering a distinct list of locations previously used by a user, as such:
function _load_locations_for_user(){
global $user;
$sql='SELECT distinct a.lid, a.name from location a, location_instance b, node c ';
$sql.='where a.lid = b.lid and b.nid = c.nid and c.type in ("profile","jammii_contrib") and c.uid ='.$user->uid.' order by name';
//print($sql);
$locations=array();
$result = db_query($sql);
while ($res = db_fetch_object($result)) {
$locations[$res->lid] = $res->name;
}
return $locations;
}
and then adding a checkbox in the hook_locationapi to the editing form to allow a user to select one of these, as such:
case 'mylocations':
$location_options = array();
$location_options = _load_locations_for_user();
return array(
'#type' => 'select',
'#title' => t('My Locations'),
'#options' => $location_options,
'#default_value' => $obj,
'#description' => t('select from previously entered locations'),
'#attributes' => NULL,
'#required' => ($a4 == 2),
);
we will then process that location id and handle it from there (still working on that).
just wanted to make sure this is in line with your thinking on this module.
thanks,
m
Comments
Comment #1
yrre7 commentedDoes this work for version 5?
Comment #2
marqpdx commentedi don't think so, but i'm not positive. only tested w/ D6 (and haven't used D5 for too long to remember).
Comment #3
yesct commentedmarking as a duplicate of #269873: [master]Allow selection of previously defined locations
(but look and see if one approach can help the other)