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

yrre7’s picture

Does this work for version 5?

marqpdx’s picture

i don't think so, but i'm not positive. only tested w/ D6 (and haven't used D5 for too long to remember).

yesct’s picture

Status: Active » Closed (duplicate)

marking as a duplicate of #269873: [master]Allow selection of previously defined locations

(but look and see if one approach can help the other)