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, 4 months ago.

We have moved to a support ticketing system and our forums are now closed.

Open Support Ticket
  • Author
    Posts
  • #20631

    adriangraham
    Expired Member
    Post count: 426

    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

    #20639

    Simone
    Expired Member
    Post count: 3515

    Hi 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.

    #20659

    adriangraham
    Expired Member
    Post count: 426
    #20665

    Simone
    Expired Member
    Post count: 3515

    try 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 />';
    												
    										}
    					?>
    #20666

    adriangraham
    Expired Member
    Post count: 426

    Works! 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.

    #20667

    Simone
    Expired Member
    Post count: 3515

    You copied fast, a second later it was in a code section 🙂

    Glad it worked.

    #20668

    adriangraham
    Expired Member
    Post count: 426

    What great service. Thanks.

    #20722

    Paolo
    Site Admin
    Post count: 31211

    BTW, if you move that template in your active theme inside a folder named geodirectory, you will not lose your changes after next update.

    Thx

    #20725

    adriangraham
    Expired Member
    Post count: 426

    Paolo, 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

    #20728

    Paolo
    Site Admin
    Post count: 31211

    Files 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

    #20769

    adriangraham
    Expired Member
    Post count: 426

    Fantastic, thanks!

Viewing 11 posts - 1 through 11 (of 11 total)

We have moved to a support ticketing system and our forums are now closed.

Open Support Ticket
20% Discount Offer
Hurry! Get your 20% discount before it expires. Get 20% Discount