Search Results for 'sf_current_query'

Forums › Forums › Search › Search Results for 'sf_current_query'

Viewing 7 results – 351 through 357 (of 357 total)
  • Author
    Search Results
  • #30310

    Anonymous
    Inactive

    That doesn’t work. I used the following code:

    <?php //Get a single fields values using labels
    //replace 1526 with the ID of your search form
    global $searchandfilter;
    $sf_current_query = $searchandfilter->get(14458)->current_query();
    echo $sf_current_query->get_field_string(“_sft_category”);
    ?>

    The output is:

    Categories: All Categories

    What I had before was better since it displayed the proper category.

    What I’m looking for is a way to display:

    Category: CategoryName

    And have the category linked to display the output as if selecting from the dropdown instead of a different layout.

    This is the current page below which is almost there.

    http://whazat.ca/resource-library/

    #26959

    Anonymous
    Inactive

    Just an update.
    I tried to use following code but it seems that a function does not exists:

    <?php
    //Get an array of objects containing data for the current search/filter
    //replace 1526 with the ID of your search form
    global $searchandfilter;
    $sf_current_query = $searchandfilter->get(1526)->current_query();
    var_dump($sf_current_query->get_array());
    ?>

    ERROR: Fatal error: Call to a member function get() on a non-object in …


    Anonymous
    Inactive

    THANK YOU so much Ross for helping with my prior questions that are now RESOLVED.

    Now I moved my Resources section that uses Search and Filter Pro live http://leadernet.org/featured-resources/ The search output goes to post type archive http://leadernet.org/resources/ .
    When no search is performed I need this archive page title to say “Showing results for all resources” vs YOU SEARCHED FOR: nothing

    I can’t figure it out.
    I can check for the length of of my text entry $my_search_term
    I’m lost trying to have an indicator of none of taxonomy checkboxes being selected.

    $my_search_term = $sf_current_query->get_search_term();
    $taxonomies = $sf_current_query->get_fields_html($fields, $args);
    echo “<br> search term length is” . strlen($my_search_term); — is 0 when none in text box
    echo “<br> term array length is” . count($taxonomies); — always 1 no matter selections

    What am I missing?

    Looking forward to your guidance, Nina

    #26753

    Ross
    Keymaster

    Hi Nina

    It should be like the example I showed you – I’ve reformatted it to make it more readable:

    $fields = array(
    	"_sft_leadership",
    	"_sft_management",
    	"_sft_governance",
    	"_sft_crosscutting"
    );
    
    $args = array(
    	"field_delim" => "<br />",
    	"delim" => ", ",
    	"show_all_if_empty" => true
    );
    
    echo $sf_current_query->get_fields_html($fields, $args);

    field_delim is the delimiter between the data for each field,
    delim is the delimiter between the actual options selected within a field

    Thanks

    #26674

    Anonymous
    Inactive

    Hello again Ross and thank you for your guidance!

    I installed updated plugin. I saw the class code that utilizes replacing args.

    I still have two questions:

    Question 1. if this code is correct – meaning should $args be where it is now:

    echo $sf_current_query->get_fields_html(
    array( “_sft_leadership”, “_sft_management”, “_sft_governance”, “_sft_crosscutting” )
    $args
    );

    OR it should go inside of the () like I’m guessing – please see below

    echo $sf_current_query->get_fields_html(
    array( “_sft_leadership”, “_sft_management”, “_sft_governance”, “_sft_crosscutting”, $args )

    );

    Question 2. After you confirm which version to use, I am not clear where to put this code.
    When I try to add “my guess” version on the top of the archive page I see that args are not being replaced.

    I on purpose changed the args to be explicitly different

    $args = array(
    “field_delim” => “X”,
    “delim” => “,Y “,
    “show_all_if_empty” => false
    );

    But when I use echo to output them, they come as: args are: , , – link to archive page is below
    http://leadernetnina.wpengine.com/resources/?_sf_s=manager&_sft_leadership=leading-change%2Cmotivation

    Sorry for being dense. As I said I’m a beginner.
    Really need your help with this critical project.

    Thank you again, Nina

    #26581

    Ross
    Keymaster

    Hi Nina

    I noticed a PHP error in the active query class so I’ve just emailed you a fix.

    Once you get that, you can pass an array of arguments to the function, which controls the delims between the fields, please see:

    $args = array(
    	"field_delim" => "",
    	"delim" => ", ",
    	"show_all_if_empty" => true
    );
    
    echo $sf_current_query->get_fields_html(
    	array( "_sft_leadership", "_sft_management", "_sft_governance", "_sft_crosscutting" )
    	$args			
    );

    Hope that helps!

    – a word of warning, there is still some functionality to add to this class, and as this is the first version, I already think that the syntax for accessing the methods of this class might change – be sure to keep an eye on the changelogs in the next couple of updates.

    Thanks


    Anonymous
    Inactive

    Hello Ross,

    when I select multiple checkboxes in my form the URL string has terms separated by comma(%2C)
    http://leadernetnina.wpengine.com/resources/?_sft_leadership=culture%2Cemotional-intelligence%2Cleading-change

    when I output the search variables on the page using your guidance:

    <?php
    echo $sf_current_query->get_fields_html(
    array( “_sft_leadership”, “_sft_management”, “_sft_governance”, “_sft_crosscutting” )
    );

    ?>

    I get this result: Leadership: CultureEmotional IntelligenceLeading Change
    How do I turn output for user into: Culture, Emotional Intelligence, Leading Change ?

    Thank you so much for your help!
    – Nina

Viewing 7 results – 351 through 357 (of 357 total)
Search & Filter Support
Privacy Overview

This website uses cookies so that we can provide you with the best user experience possible. Cookie information is stored in your browser and performs functions such as recognising you when you return to our website and helping our team to understand which sections of the website you find most interesting and useful.

We also use cookies to store items in your cart as well as allowing your to login on the site.

You can adjust all of your cookie settings by navigating the tabs on the left hand side.

By continuing to use this site, you also agree to our Privacy Policy.