How would I add text from the "Near" field to appear in results after "distance"
This topic contains 10 replies, has 3 voices, and was last updated by adriangraham 10 years, 11 months ago.
We have moved to a support ticketing system and our forums are now closed.
Open Support Ticket-
AuthorPosts
-
November 5, 2014 at 9:53 am #20631
Hi there,
When I type a value into the “near” field in “GD > Search” I think it would be great to have that value in the search results after the km/miles value…. so instead of it saying “Listing Title” and then for example “2.2 miles” or “2.2 km”… it would say “2.2 miles from Dublin” or whatever was typed into the near field.
What would be involved in doing this?
Thanks as always!
Adrian
November 5, 2014 at 1:04 pm #20639Hi Adrian, it is a little bit tricky, but you can edit this and make it work:
open listing-listview.php in /wp-content/plugins/geodirectory/geodirectory_templates
find this block
<?php if (round((int)$distance,2) == 0){ $uom = get_option('geodir_search_dist_2'); $distance = geodir_calculateDistanceFromLatLong ($startPoint,$endPoint,$uom); echo round($distance).' '.$uom.'<br />'; }else{ echo round($distance,2).' '.$uom.'<br />'; } ?>it’s between row 77 and 86
replace this block with
<?php if (round((int)$distance,2) == 0){ $uom = get_option('geodir_search_dist_2'); $distance = geodir_calculateDistanceFromLatLong ($startPoint,$endPoint,$uom); echo round($distance).' '.$uom.' from '.$_REQUEST['snear'].' <br />'; }else{ echo round($distance,2).' '.$uom.' from <br />'; } ?>You will have the result, as per seen on the screenshot (tested on my demo site)
Sidenote: the modification needs to be redone if a GD update will be released.
November 5, 2014 at 1:30 pm #20659Great fast reply Simone…. it works… but only listings in the EXACT area where you are searching and not even ones beside it
for example look at this URL with it implemented:
and
and
November 5, 2014 at 1:35 pm #20665try this
<?php if (round((int)$distance,2) == 0){ $uom = get_option('geodir_search_dist_2'); $distance = geodir_calculateDistanceFromLatLong ($startPoint,$endPoint,$uom); echo round($distance).' '.$uom.' from '.$_REQUEST['snear'].' <br />'; }else{ echo round($distance,2).' '.$uom.' from '.$_REQUEST['snear'].' <br />'; } ?>November 5, 2014 at 1:39 pm #20666Works! Thanks
Note to anyone else using this…. I had to change the quotation marks in Simones reply as they were getting formatted wrong as it’s not in a CODE section above
I think this would be a nice change in the next release.
November 5, 2014 at 1:41 pm #20667You copied fast, a second later it was in a code section 🙂
Glad it worked.
November 5, 2014 at 1:41 pm #20668What great service. Thanks.
November 5, 2014 at 7:07 pm #20722BTW, if you move that template in your active theme inside a folder named geodirectory, you will not lose your changes after next update.
Thx
November 5, 2014 at 7:19 pm #20725Paolo, this is interesting as I am worried about a couple of changes I’ve made getting over written…. can you explain exactly what you mean?
Thanks,
Adrian
November 5, 2014 at 7:42 pm #20728Files in
plugins/geodirectory/geodirectory-templates/
can be copied in
themes/your-active-theme/geodirectory/ (folder to be created)
And the plugin will start using your copy of the file.
Thx
November 5, 2014 at 11:03 pm #20769Fantastic, thanks!
-
AuthorPosts
We have moved to a support ticketing system and our forums are now closed.
Open Support Ticket