SOLVED: Radius Search using PHP form plugin?

Status
Not open for further replies.

sn00ze

New Member
Hi all,
I'm trying to complete a custom search form.
I have been using {placeholders} and url filtering in a php form plugin... with some success, but have hit a wall with partially tricky SQL select involving a radius search.
It would be easiest if I could access and edit the SQL query that is generating my list?
Can this be done?
here is my code so far... and the search form (what's working so far..) can be seen here: http://glutenfreedietfinder.com.au/

Code:
$app = JFactory::getApplication();
// build URL
$url = 'index.php?option=com_fabrik&view=list&listid=5&fabrikdebug=1&resetfilters=1';
 
// im_looking_for
$strTemp = '';
$strTemp = '{front_page_search___im_looking_for}';
if($strTemp !== ''){
  $url .= '&fabrik_list_filter_all_5_com_fabrik_5=' . $strTemp;
}
// category
$strTemp = '';
$strTemp = '{front_page_search___category_raw}';
if($strTemp !== '00'){
  $url .= '&new_entry___category=' . $strTemp;
}
 
// Speciality type
$strTemp = '';
$strTemp = '{front_page_search___specialty_type}';
if($strTemp !== ''){
  $url .= '&new_entry___specialty_type=' . $strTemp;
}
 
// Radius search
preg_match('/([\d.-]+).+?([\d.-]+)/', $formModel->formData['front_page_search___location_Geocode'], $matches);
$lat = (float)$matches[1];
$long = (float)$matches[2];
 
//SELECT QUERY
//$query = $app->input->getInt( 'formid', 0 );
 
//$db = JFactory::getDbo();
//$query = $db->getQuery(false);
 
// debuggery
$app->enqueueMessage("lat: ". $lat . " long: " . $long ." Query: ". $query);
//var_dump($this->data);exit;
 
$app->redirect($url);
 
Perhaps I could perform my query in the php plugin then join the results with those from the QueryString?
or maybe, perform my search query and store it in a session? then filter further with the QueryString?
 
Have you tried experimenting with our radius search plugin?

You should be able to see what we submit by way of posted data (using Firebug, and looking at the Net tab). That should then show you what you need to put on the query string to do a radius search.

-- hugh
 
hey thanks!
ok so a lot GET 's are being sent. Here's a sample that occur before the final POST:

Code:
http://maps.googleapis.com/maps/gen_204?imp=smimps%3DILptYScJfEA,I3MqWYbQEgH%26z%3D7&cad=src:apiv3,ts:3th0tt
http://maps.googleapis.com/maps/gen_204?ev=api_viewport&cad=host:glutenfreedietfinder.com.au,v:15,vr:1,r:1,mt:m,c:-6.506142%2C107.962594,sp:2.94687x4.39453,size:400x270,relsize:0.13,token:6m0jf3orwu,src:apiv3,ts:3th10i
http://maps.googleapis.com/maps/gen_204?ev=api_viewport&cad=host:glutenfreedietfinder.com.au,v:15,vr:1,r:1,mt:m,c:46.984366%2C0.613984,sp:2.02326x4.39453,size:400x270,relsize:0.13,token:6m0jf3orwu,src:apiv3,ts:3th19l
http://maps.googleapis.com/maps/gen_204?ev=api_viewport&cad=host:glutenfreedietfinder.com.au,v:15,vr:1,r:1,mt:m,c:-26.621663%2C152.95936,sp:2.65148x4.39453,size:400x270,relsize:0.13,token:6m0jf3orwu,src:apiv3,ts:3th1fn

Then a POST:
Code:
    http://glutenfreedietfinder.com.au/index.php?option=com_fabrik&view=list&listid=5&Itemid=115&resetfilters=0&clearordering=0&clearfilters=0

sorry for my dumbs :confused: but unsure how to decipher the GETs...was hoping for long/lat looking numbers somewhere...
and then how to use them in the query string!
 
For this to work, would i need to load the list using the php plugin and queryfilter as above, then send the radius search like GETs (using a php list plugin?) and filter the list?
 
I think you are going to have to add the radius search plugin to the list to even start to get anywhere with this. Then your php code in your form redirect plugin might look similar to this:

PHP:
$radiusSearchPluginOrder = 0;
$url = "index.php?option=com_fabrik&view=list&listid=5&resetfilters=1";
 
$o = FabrikString::mapStrToCoords($data['places_search___location_raw']);
 
$url .= '&radius_search_lat'  $radiusSearchPluginOrder . '=' . $o->lat;
$url .= '&radius_search_lon' . $radiusSearchPluginOrder . '=' . $o->lon;
$url .= '&radius_search_distance' . $radiusSearchPluginOrder . '=' . $data['places_search___radius_raw'];
$url .= '&radius_search_active' . $radiusSearchPluginOrder . '=1';
 
$app = JFactory::getApplication();
$app->redirect($url);

$radiusSearchPluginOrder is the order of the radius search plugin in the list you are redirecting to. Generally, if the list only has one plugin it will be 0.
Replace 'places_search___location_raw' with the full name of the search form map element
Repalce 'places_search___radius_raw' with the field which is storing the search map element's radius distance.
 
That worked, thanks guys!
Yes, the radius search plugin needed to be added to the list.
I hard coded the radiusSearchPluginOrder into the string... that will it be ok?

Here is the code for anyone else interested, note its $o->long not $o->lon:
Code:
$url = "index.php?option=com_fabrik&view=list&listid=5&resetfilters=1";
 
$o = FabrikString::mapStrToCoords($data['front_page_search___location_Geocode_raw']);
 
  $url .= '&radius_search_lat0=' . $o->lat;
  $url .= '&radius_search_lon0=' . $o->long;
  $url .= '&radius_search_distance0=' . '{front_page_search___within_kms}';
  $url .= '&radius_search_active0=1';
 
$app = JFactory::getApplication();
$app->redirect($url);
 
sure that will work, I was just trying to make it obvious that the radiusSearchPluginOrder value was applicable to all of the querystring's properties.
 
Status
Not open for further replies.
We are in need of some funding.
More details.

Thank you.

Members online

Back
Top