Forums Forums Search & Filter Pro How to style the search data

Viewing 10 posts - 1 through 10 (of 30 total)
  • Anonymous
    #43504

    Hi,

    I have used the following code to show the specific taxonomy fields within the search form:

    <?php
    	global $searchandfilter;
    	$sf_current_query = $searchandfilter->get(339)->current_query();
    	echo $sf_current_query->get_fields_html(
    		array("_sft_length", "_sft_rate", "_sft_guest", "_sft_location", "_sft_toy")
    	);
    ?>

    However this code displays the full list of fields continuously.

    Is there a way to style and list only the content from each taxonomy used for a search, after form submission?

    Further to this, once the content is displaying independently is there a way to assign a small “cross” to be able to remove this specific field from the search?

    Page found at http://www.cascadetest.co.uk/oneocean.com/charter-overview/

    Trevor
    #43524

    I think that these are 2 separate questions? Let’s take the first one first. If I click on a yacht length, I might see this:

    Yacht Length: 40-50m
    Yacht Rate: All Yacht Rates
    Yacht Guests: All Yacht Guests
    Yacht Locations: All Yacht Locations
    Yacht Hero Toys: All Yacht Hero Toys Found 6 Results
    Page 1 of 1

    You want it to show something like this:

    Yacht Length: 40-50m
    Found 6 Results
    Page 1 of 1

    And what if it is the first time on the page, with no search? Only this to show?

    Found 10 Results
    Page 1 of 2

    Anonymous
    #43530

    Correct, although I’d like to be able to remove the “Yacht Length” and all subsequent category titles all together.

    Eventually I’d like it to show:

    x 40-50m
    Found 6 results
    Page 1 of 1

    Where the “x” is an active link to remove it from the active search.

    And correct about the first time on the page.

    Trevor
    #43540

    Ah. I understand. I will talk to Ross and get back to you.

    Trevor
    #43562

    Hi

    Ross tells me that there is additional functionality on this filter, he says this will be useful to you:

    get_fields_html(array(), array('show_all_if_empty' => false))
    

    Instead of what you used. As to the other x link feature, he says it is not there now, but is coming (as is an easier way to what you have above), but this may be useful to you:

    http://www.designsandcode.com/documentation/search-filter-pro/accessing-search-data/#Getan_array_offilterswithvalues_and_labels

    Anonymous
    #43565

    Hi,

    I’ve added the code but it seems to be throwing an error on the array. Am I missing something?
    <?php
    //Get a multiple fields values by passing an array of field names
    //replace 1526 with the ID of your search form
    global $searchandfilter;
    $sf_current_query = $searchandfilter->get(339)->current_query();
    echo $sf_current_query->get_fields_html(array(), array(‘show_all_if_empty’ => false)
    );
    ?>

    I’ve also added the code from the supplied link but it throws back the following error:
    array(2) { [“_sft_length”]=> array(5) { [“name”]=> string(13) “Yacht Lengths” [“singular_name”]=> string(12) “Yacht Length” [“all_items_label”]=> string(17) “All Yacht Lengths” [“type”]=> string(8) “taxonomy” [“active_terms”]=> array(1) { [0]=> array(4) { [“id”]=> int(6) [“name”]=> string(6) “40-50m” [“value”]=> string(6) “40-50m” [“count”]=> int(5) } } } [“_sft_toy”]=> array(5) { [“name”]=> string(15) “Yacht Hero Toys” [“singular_name”]=> string(14) “Yacht Hero Toy” [“all_items_label”]=> string(19) “All Yacht Hero Toys” [“type”]=> string(8) “taxonomy” [“active_terms”]=> array(1) { [0]=> array(4) { [“id”]=> int(16) [“name”]=> string(7) “Freezer” [“value”]=> string(7) “freezer” [“count”]=> int(5) } } } }

    Found on the same web link as before.

    Trevor
    #43566

    I will ask Ross to take a look.

    Trevor
    #43567

    Try this (BTW, please use the code tags in the editor toolbar to enclose code 🙂 ):

    get_fields_html(array("_sft_length", "_sft_rate", "_sft_guest", "_sft_location", "_sft_toy"), array('show_all_if_empty' => false));
    
    Trevor
    #43570

    Arrrggghh

    Can you even see the toolbar? Darn. I didn’t think of that. The WP quick enclose/close code is the back tick (next to the 1 key). Works in the WP Visual editor too!!

    Anonymous
    #43600

    Trevor, works brilliantly, thanks.

    The only other thing which we need to be able to do is to remove the taxonomy title when it reveals.

    Currently when a search is made it shows:

    “Yacht Length: 40-50m”

    Is there a way to remove the “Yacht Length” so it only shows the search data?

Viewing 10 posts - 1 through 10 (of 30 total)