Active
Project:
Geobrowser
Version:
5.x-7.0
Component:
Code
Priority:
Normal
Category:
Feature request
Assigned:
Unassigned
Reporter:
Created:
2 Sep 2008 at 04:11 UTC
Updated:
4 Sep 2008 at 07:21 UTC
Given that the location module seems to be simply used for storage of lat/lon data against a node, how about making this a bit more flexible so other modules can provide this simple data set via a custom query?
Currently one would need to hack the geobrowser module to change where the lat/lon data comes from, but by exposing a hook that could be left to other modules.
// Call a hook that'll let modules define their own location node queries.
foreach (module_implements('geobrowser_get_nodes_sql') as $module) {
$function = $module .'_geobrowser_get_nodes_sql';
$get_nodes = $function($view);
}
// If no other module offered a query, use the standard location module to retrieve geo data from.
if (!$get_nodes) {
$get_nodes = "
SELECT
{location}.latitude AS geobrowser_lat,
{location}.longitude AS geobrowser_lon,
{location}.eid AS geobrowser_vid,
{node}.nid AS geobrowser_nid,
tid".$_REQUEST['current_tree']." as term_node_tid,
{node}.title AS node_revisions_title,
{votingapi_vote}.value IS NULL AS isnull
FROM {location}
INNER JOIN {node} ON {node}.vid = {location}.eid
$layers_sql
LEFT JOIN {votingapi_vote} ON {node}.nid = {votingapi_vote}.content_id
WHERE
";
$get_nodes .= "{location}.longitude < %s AND {location}.longitude > %s AND {location}.latitude < %s AND {location}.latitude > %s"; //filtering so that we are only selecting nodes within our view screen.
}
Comments
Comment #1
phayes commentedTHis is great! Thank you
Comment #2
nicolash commentedOoops, I copied that loop from the views module...
$get_nodes = $function($view);
should only be
$get_nodes = $function();
where that function then returns the appropriate SQL - no need for any arguments really.