Search Results for 'sf_current_query get_array field [value]'

Forums › Forums › Search › Search Results for 'sf_current_query get_array field [value]'

Viewing 4 results – 1 through 4 (of 4 total)
  • Author
    Search Results
  • #169245

    Trevor
    Participant

    But I don’t access it using get_fields_html. I do it like this:

    global $searchandfilter;
    $sf_current_query = $searchandfilter->get(934)->current_query()->get_array();
    $my_post_type = $sf_current_query[post_type][active_terms][0][value];
    #104843

    Anonymous
    Inactive

    I have two forms that I’d like to work together. The search form sits in the header and is only a search input (sfid 5729). The Filter form sits in the sidebar and has dropdowns for 3 custom taxonomies plus a from and to date (sfid 5727). They both are set to display in archive.php. The search form will use a url such as this, https://boardofednew.webdev.idaho.gov/search/?_sf_s=test.

    The archive.php sidebar is implemented with content aware sidebars plugin and the sf widget for this filter form is set to display in it (5727).

    So when I access the current press releases from the menu using url https://domainnamehere/resources/?_sft_resourcetype=press-releases and archive.php the filter form (5727) displays properly along with the filtered results for press releases. However, when I use the search form from the header (5729), it displays search results properly using archive.php, but it does not display the filter form (5757) in the sidebar. My intent is to return the search results for the term, then filter it further with the form in the sidebar. Code for archive.php follows:

    ‘
    <?php
    /**
    *
    * Description: Generic Index Page
    *
    * Used to display archive-type pages if nothing more specific matches a query.
    * For example, puts together date-based pages if no date.php file exists.
    *
    * If you’d like to further customize these archive views, you may create a
    * new template file for each one. For example, tag.php (Tag archives),
    * category.php (Category archives), author.php (Author archives), etc.
    *
    * @link https://codex.wordpress.org/Template_Hierarchy
    *
    * @package FoundationPress
    * @since FoundationPress 1.0.0
    */
    ?>
    <?php get_header(); ?>

    <main id=”main” class=”body-content row column” role=”main”>
    <?php get_template_part(‘template-parts/breadcrumbs’); ?>
    <div class=”medium-8 columns”>
    <header class=”page-header”>
    <?php
    global $searchandfilter;
    $sf_current_query_1 = $searchandfilter->get(5279)->current_query(); // 5279 is search input only
    $search_term = $sf_current_query_1->get_search_term();
    $sf_current_query_2 = $searchandfilter->get(5277)->current_query(); // 5277 is custom taxonomy filter input only
    $sarr = $sf_current_query_2->get_array();
    $fromDate = $sarr[_sf_post_date][active_terms][0][value] ;
    $toDate = $sarr[_sf_post_date][active_terms][1][value];
    $type = $sf_current_query_2->get_field_string(“_sft_resourcetype”);
    if ($type) {
    $type = substr($type, strpos($type, “:”) + 1);
    }
    $topic = $sf_current_query_2->get_field_string(“_sft_primarytopic”);
    if ($topic) {
    $topic = substr($topic, strpos($topic, “:”) + 1);
    }
    $audience = $sf_current_query_2->get_field_string(“_sft_audience”);
    if ($audience) {
    $audience = substr($audience, strpos($audience, “:”) + 1);
    }
    if ($search_term) {
    $type = “Search Results”;
    }
    echo ‘<h1>’ . $type . ‘</h1>’;
    echo ‘<h2 class=”subheader”>’ . $topic . ” / “. $audience . ‘</h2>’;
    echo ‘<p class=”small”>Note: Select date range or change resource, topic or audience as needed.</p>’;
    ?>
    </header><!– .page-header –>
    <?php if (have_posts()) : ?>
    <section <?php post_class(); ?> >
    <?php while (have_posts()) : the_post(); ?>
    <?php get_template_part( ‘template-parts/content’, get_post_format() ); ?>
    <?php endwhile; ?>
    <?php else : ?>
    <?php get_template_part( ‘template-parts/content’, ‘none’ ); ?>
    </section>
    <?php endif; // End have_posts() check. ?>
    <?php /* Display navigation to next/previous pages when applicable */ ?>
    <?php if ( function_exists( ‘foundationpress_pagination’ ) ) { foundationpress_pagination(); } else if ( is_paged() ) { ?>
    <nav id=”post-nav”>
    <div class=”post-previous”><?php next_posts_link( __( ‘← Older posts’, ‘foundationpress’ ) ); ?></div>
    <div class=”post-next”><?php previous_posts_link( __( ‘Newer posts →’, ‘foundationpress’ ) ); ?></div>
    </nav>
    <?php } ?>
    </div>
    <?php get_sidebar(); ?>
    </main>
    <?php get_footer(); ?>
    ‘

    #70909

    Anonymous
    Inactive

    function sf_filter_query_args( $query_args, $sfid ) {

    if($sfid==1225){

    global $searchandfilter;
    $sf_current_query = $searchandfilter->get(1225)->current_query();

    $sf_current_query->get_field_string(“_sfm_event_archives”);
    $_sfm_event_archives_array = $sf_current_query->get_array();
    $archive_is_check = $_sfm_event_archives_array[_sfm_event_archives][active_terms][0][value];

    //print_r($archive_is_check);

    if($archive_is_check != ‘1’){
    $args_custom = array(
    “meta_key” => “imic_event_start_dt”,
    “orderby” => “meta_value_num”,
    “order” => “ASC”,

    “meta_query” => Array (
    “event_archives” => Array (
    “key” => “event_archives”,
    “value” => “0”
    )
    )
    );

    $query_args = array_merge($query_args, $args_custom);
    }

    // si aucun filtre d’appliqué
    //if($sf_current_query->is_filtered()!=1){}

    }

    return $query_args;

    }
    add_filter( ‘sf_edit_query_args’, ‘sf_filter_query_args’, 100, 2 );

    #70903

    Anonymous
    Inactive

    Hi,
    thanks for your help!!!
    It wasn’t the wpml plugin,
    but the custom code (that I was sure it wasn’t in cause)
    I had to add the bold section here to make it work

    
    function sf_filter_query_args( $query_args, $sfid ) {
    
      if($sfid==1225){
    	
    	global $searchandfilter;
    	$sf_current_query = $searchandfilter->get(1225)->current_query();
    	
    	
    	$sf_current_query->get_field_string("_sfm_event_archives");
    	$_sfm_event_archives_array = $sf_current_query->get_array();
    	$archive_is_check = $_sfm_event_archives_array[_sfm_event_archives][active_terms][0][value];
    	
    	//print_r($archive_is_check);
    	
    	if($archive_is_check != '1'){
    		$args_custom = array(
    			<strong>"meta_key" => "imic_event_start_dt",
    			"orderby" => "meta_value_num",
    			"order" => "ASC",</strong>
    			"meta_query" => Array ( 
    		  		"event_archives" => Array ( 
    					"key" => "event_archives",
    					"value" => "0"
    				)
    			)
        	);
    		
    		$query_args = array_merge($query_args, $args_custom);
    	}
    	
    	// si aucun filtre d'appliqué
    	//if($sf_current_query->is_filtered()!=1){}
    
      }
      
      return $query_args;
    
    }
    add_filter( 'sf_edit_query_args', 'sf_filter_query_args', 100, 2 );
    

    Thanks again for your help guys!
    Really nice plugin!

Viewing 4 results – 1 through 4 (of 4 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.