• Resolved strap

    (@strap)


    Hello Greg,

    i’m opening a separate topic for another question.

    I’ve managed to add into the wordpress database, all the italian Region>Province>City data. So that city has the province as parent, and provinces have their region as parent.

    Everything wors good, i can use the autocomplete feature in the search form from the “Maps and Locations” addon and the adverts get correctly linked.

    What is driving me crazy, is that i have 8000 entries in the dropdown menu for Location. This is causing the website to be reaaaaallly slow in loading pages where the location dropdown is present. Also the client browser stops worinkg for 5-10 seconds while opening the menu.

    I’ve tryied to adapt the snippet “dependant taxonomy dropwdown” that i already use for categories, but unfortunately i had some problems. As you may imagine, i’ve messed up the code in the “Maps & Locations” but shouldn’t be the right thing to do probably.

    For the little i was able to try, making the dropdown dynamic really makes the page load much quicker, and solves client browser problems.

    Can you suggest a clean implementation or another solution?

    Thanks a lot,
    have a nice day.

    Stefano

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Author Greg Winiarski

    (@gwin)

    Hi,
    you can use the Location field with Dependant Taxonomy Dropdown snippet by adding the code below in your snippets file

    
    add_filter( "adverts_form_load", function( $form ) {
        if( $form["name"] != "advert" ) {
            return $form;
        }
        
        foreach( $form["field"] as $key => $field ) {
            if( $field["name"] === "adverts_location" ) {
                $form["field"][$key]["type"] = "adverts_field_select_dependant";
                $form["field"][$key]["options_callback"] = null;
                $form["field"][$key]["options"] = array();
                $form["field"][$key]["dtd_use_taxonomy"] = "advert_location";
            }
        }
        
        return $form;
    }, 9000 );
    

    It would be also best if in wp-admin / Classifieds / Options / Maps and Locations panel you would have the “[adverts_add] Configuration” -> “Location Field” set to “Dropdown filed with Location taxonomy.”.

    Thread Starter strap

    (@strap)

    Hi,

    everything works! How easy it was..

    Thanks a lot,
    have a nice day!

    Plugin Author Greg Winiarski

    (@gwin)

    Hi,
    ok great i am glad you have it resolved :). I am marking this thread as resolved then.

Viewing 3 replies - 1 through 3 (of 3 total)

The topic ‘Location module + dependant taxonomy dropdown snippet’ is closed to new replies.