I've noticed that a location which is marked with is_primary flag could be placed with different order in location collection. It's not easy to customize since we need to detect the primary location first. I suggest to modify function location_load_locations in that way that is_primary=1 is always the first one, rewritten function is:
function location_load_locations($id, $key = 'vid') {
if (empty($id)) {
// If the id is 0 or '' (or false), force returning early.
// Otherwise, this could accidentally load a huge amount of data
// by accident. 0 and '' are reserved for "not applicable."
return array();
}
if ($key == 'genid') {
$result = db_query('SELECT i.lid FROM {location_instance} AS i INNER JOIN {location} AS l ON l.lid = i.lid WHERE '. db_escape_table($key) .' = \'%s\' ORDER BY l.is_primary DESC', $id);
}
else {
$result = db_query('SELECT i.lid FROM {location_instance} AS i INNER JOIN {location} AS l ON l.lid = i.lid WHERE '. db_escape_table($key) .' = %d ORDER BY l.is_primary DESC', $id);
}
$locations = array();
while ($lid = db_fetch_object($result)) {
$locations[] = location_load_location($lid->lid);
}
return $locations;
}
Comments
Comment #1
yesct commentedcan you make a patch:
http://drupal.org/patch/create
Comment #2
desunit commentedHere you are the patch:
Comment #3
desunit commentedComment #4
ankur commentedThat is_primary column is like the human appendix: it has some use at some point and then became obsolete. Also, with the new features in fields, it should (or will) be possible to distinguish your locations within an entity from each other by some other means.