Forums Forums Search Search Results for 'active_terms 0 name'

Viewing 10 results - 11 through 20 (of 45 total)
  • Author
    Search Results

  • Anonymous
    Inactive

    How to get all name terms of current filtered

    I use current_query is found —- taxonomy [active_terms] —- in array but I dont to know
    how to get term name

    I need to do function like this f

    Thank you

    #173884

    In reply to: Select Box Like Ted


    Anonymous
    Inactive

    Thanks!

    Got it working using the links you supplied.

    $sf_current_types_query = $searchandfilter->get(299)->current_query()->get_array();
    $currentType=$sf_current_types_query['post_types']['active_terms'][0]['name'];
    if ( empty($currentType) ) {
    	echo '';
    } else {
            echo '<li>' . $sf_current_types_query['post_types']['active_terms'][0]['name'] . '<i class="fa fa-times"></i></li>';
    }
    						
    ?>
    #173861

    In reply to: Select Box Like Ted


    Anonymous
    Inactive

    This is the output (the terms are there for post_types—pages and practices) but I can’t seem to display it with in the same manner as the categories.

    <?php $args = array(
    	"str" 					=> '<ul class="filters-list"><li>%2$s<i class="fa fa-times"></i></li></ul>', 
    	"delim" 				=> array('<i class="fa fa-times"></i></li> <li>', '–'), 
    	"field_delim"				=> ' , ', 
    	"show_all_if_empty"			=> false 
    						);
    						
    echo $sf_current_query->get_fields_html(
    	array("_sft_category","post_types"), 
    	$args
    ); 
    												
    echo '<pre>';
    print_r($sf_current_query);
    echo '</pre>';
    ?>

    output:

    Search_Filter_Active_Query Object
    (
    [sfid] => 299
    [is_set:Search_Filter_Active_Query:private] => 1
    [query_array:Search_Filter_Active_Query:private] => Array
    (
    [_sft_category] => Array
    (
    [name] => Categories
    [singular_name] => Category
    [all_items_label] => All Categories
    [type] => taxonomy
    [active_terms] => Array
    (
    [0] => Array
    (
    [id] => 56
    [name] => Community Development
    [value] => community-development
    [count] => 5
    )

    [1] => Array
    (
    [id] => 57
    [name] => Environment
    [value] => environment
    [count] => 1
    )

    )

    )

    [post_types] => Array
    (
    [name] => Post Types
    [singular_name] => Post Type
    [all_items_label] => All Post Types
    [type] => post_type
    [active_terms] => Array
    (
    [0] => Array
    (
    [name] => Practices
    [value] => practice
    )

    )

    )

    )

    [form_fields:Search_Filter_Active_Query:private] => Array
    (
    [search] => Array
    (
    [type] => search
    [heading] =>
    [placeholder] => Search …
    [accessibility_label] => Enter Your Search Terms
    )

    [_sft_category] => Array
    (
    [type] => category
    [input_type] => checkbox
    [heading] =>
    [accessibility_label] => Select A Topic From The List
    [all_items_label] => Topics
    [show_count] => 0
    [hide_empty] => 1
    [hierarchical] => 0
    [include_children] => 0
    [drill_down] => 0
    [sync_include_exclude] => 1
    [combo_box] => 1
    [no_results_message] =>
    [operator] => and
    [order_by] => default
    [order_dir] => asc
    [exclude_ids] =>
    [taxonomy_name] => category
    )

    [post_type] => Array
    (
    [post_types] => Array
    (
    [page] => 1
    [practice] => 1
    )

    [type] => post_type
    [input_type] => select
    [heading] =>
    [all_items_label] => All Types
    [accessibility_label] => Select Section Type From The List
    [combo_box] => 0
    [no_results_message] =>
    )

    )

    [query_str:Search_Filter_Active_Query:private] => -1
    [plugin_slug] => search-filter
    [form_settings] => Array
    (
    [use_template_manual_toggle] => 1
    [enable_taxonomy_archives] => 0
    [enable_auto_count] => 0
    [auto_count_refresh_mode] => 1
    [auto_count_deselect_emtpy] => 0
    [template_name_manual] => search.php
    [page_slug] => advanced-search
    [post_types] => Array
    (
    [practice] => 1
    )

    [post_status] => Array
    (
    [publish] => 1
    )

    [use_ajax_toggle] => 1
    [scroll_to_pos] => 0
    [pagination_type] => normal
    [custom_scroll_to] =>
    [use_relevanssi] => 1
    [use_relevanssi_sort] => 1
    [auto_submit] => 1
    [display_results_as] => archive
    [update_ajax_url] => 1
    [only_results_ajax] =>
    [ajax_target] => #search-filter-results-299
    [ajax_links_selector] => .pagination a
    [infinite_scroll_container] =>
    [infinite_scroll_trigger] => -100
    [infinite_scroll_result_class] =>
    [show_infinite_scroll_loader] => 1
    [results_per_page] => 9999999
    [exclude_post_ids] =>
    [field_relation] => and
    [default_sort_by] => date
    [sticky_posts] =>
    [default_sort_dir] => desc
    [default_meta_key] => _additional_settings
    [default_sort_type] => numeric
    [secondary_sort_by] => 0
    [secondary_sort_dir] => desc
    [secondary_meta_key] => _additional_settings
    [secondary_sort_type] => numeric
    [taxonomies_settings] => Array
    (
    [category] => Array
    (
    [include_exclude] => exclude
    [ids] => 1
    )

    [post_tag] => Array
    (
    [include_exclude] => include
    [ids] =>
    )

    [post_format] => Array
    (
    [include_exclude] => include
    [ids] =>
    )

    [luv_portfolio_categories] => Array
    (
    [include_exclude] => include
    [ids] =>
    )

    [luv_portfolio_tags] => Array
    (
    [include_exclude] => include
    [ids] =>
    )

    )

    [results_url] =>
    )

    [cache_table_name] => wp_csf_search_filter_cache
    [term_results_table_name] => wp_csf_search_filter_term_results
    [field_values] => Array
    (
    [_sft_category] => Array
    (
    [0] => community-development
    [1] => environment
    )

    [post_types] => Array
    (
    [0] => practice
    )

    )

    )

    #171986

    In reply to: Display multiple terms


    Anonymous
    Inactive

    Trevor, thanks again for spending time with me today. I really appreciated it.

    Good news, I finally figured it out!

    Here’s the happy code:

    <?php 
    
    	global $searchandfilter;
    	
    	$args = array(
    		"str" 					=> '%2$s', 
    		"delim" 				=> array(", ", " - "), 
    		"field_delim"			=> ', ', 
    		"show_all_if_empty"		=> false 
    	);
     
    $sf_current_query = $searchandfilter->get(99801)->current_query()->get_array();
    $sf_current_style_query = $searchandfilter->get(99801)->current_query()->get_fields_html(array("_sft_style", "_sft_name"),$args);
    $sf_current_cuisine_query = $searchandfilter->get(99801)->current_query()->get_fields_html(array("_sft_cuisine", "_sft_name"),$args);
    	
    echo '<strong>Filters</strong>';
    
    if ( empty($sf_current_query ) ) {
      echo ' &bull; ' . "All" . "<br /><br />";
    } else {
    
      echo ' &bull; ' . $sf_current_query['_sft_category']['active_terms'][0]['name'] . ' &bull; ' . $sf_current_query['_sfm_wpcf-location-city']['active_terms'][0]['name'] . ' &bull; ' . $sf_current_style_query . ' &bull; ' . $sf_current_cuisine_query;
    	echo "<br /><br />";
    }
    ?>

    Cheers!

    #171735

    In reply to: Display multiple terms


    Anonymous
    Inactive

    Actually, $key[‘active_terms’][0][‘name’] pulls from both the dropdown field (“Market”) and the array (“Cuisines”), so that code wouldn’t be correct. I need the dropdown selection followed by the array.

    #171733

    In reply to: Display multiple terms


    Anonymous
    Inactive

    Okay, good news, I’m making progress…

    This works for the array:

    <?php 
    
    global $searchandfilter;
    $sf_current_query = $searchandfilter->get(99801)->current_query();
    
    if ( empty($sf_current_query ) ) {
      echo '<strong>Filters</strong>' . ' &bull; ' . "All" . "<br /><br />";
    } 
      else {
        $args = array(
        "str"  => '%2$s', 
        "delim"  => array(", ", " - "), 
        "field_delim"  => ', ', 
        "show_all_if_empty"  => false 
      );
      echo '<strong>Filters</strong>' . ' &bull; ' . $sf_current_query->get_fields_html(array("_sft_cuisine", "_sft_name"), $args);
      }
    	
      echo '<br />';
    ?>

    Now I need to pull in the $key[‘active_terms’][0][‘name’] from the original code (it will display before the array).

    That will give me what I’m after…
    Filters • Florida • Caribbean, Mexican

    How do I combine it?

    #169183

    Anonymous
    Inactive

    Thank you Trevor – this outputs:

    Array
    (
        [_sft_product_cat] => Array
            (
                [name] => Product categories
                [singular_name] => Category
                [all_items_label] => All categories
                [type] => taxonomy
                [active_terms] => Array
                    (
                        [0] => Array
                            (
                                [id] => 128
                                [name] => Men's Shoes
                                [value] => mens-shoes
                                [count] => 0
                            )
    
                    )
    
            )
    
        [_sft_pwb-brand] => Array
            (
                [name] => Brands
                [singular_name] => Brand
                [all_items_label] => All Brands
                [type] => taxonomy
                [active_terms] => Array
                    (
                        [0] => Array
                            (
                                [id] => 220
                                [name] => Ted Baker
                                [value] => ted-baker
                                [count] => 0
                            )
    
                    )
    
            )
    
    )

    And the bit I need is the “value” of “_sft_pwb-brand” – i.e. “ted-baker”

    Thanks in advance 🙂

    #169120

    Anonymous
    Inactive

    Hi,

    Have an issue trying to extract post types via $postTypes1 = $sf_current_query->get_fields_html(array(“_sf_s”, “_sft_access_level”, “post_type”,”_sft_topic”));
    echo $postTypes1;

    only returns
    Access Levels: All Access Levels (ie: _sft_access_level)
    Topics: All Topics (ie: _sft_topic)

    but no post types aka Data Type.

    You can see the page results here:

    The debug structure of the query which clearly shows them here:
    Please see image link
    or
    Issue with get_fields_html

    Is this a bug with get_fields_html?

    If the Data Types are checked as filters it’s possible to retrieve them but that is different from retrieving the associated post types via get fields.

    	<?php  	
    		$postTypes1 = $sf_current_query->get_fields_html(array("_sf_s", "_sft_access_level", "post_type","_sft_topic"));
    		echo $postTypes1; 
    		//echo $sf_current_query->is_filtered();
    		$postTypesAll = $sf_current_query->get_array();
    		//var_dump($postTypesAll);
    		//print_r(array_values($postTypesAll));
    		$postTypes = array_column($postTypesAll, 'active_terms');
    		//var_dump($postTypes);
    		//print_r(array_values($postTypes));
    		$newArray = array();
    		foreach ($postTypes as $entry) {
    			$names = array_column($entry, 'name');
    		}
    		//var_dump($names);
    		//print_r(array_values($names));
    		$dataTypes = "<br>Data Types: ";
    		$breakChars = ", ";
    		//echo $dataTypes;
    		for ($i = 0; $i < count($names); $i++) {
    			$nameCompare = strcmp($names[$i], "Posts");
    			if ($nameCompare == 0) {
    				$names[$i] = 'Articles';
    			}
    			//echo $names[$i];
    			if ($i < count($names) - 1) {
    				echo $breakChars;
    			}
    		}
    		//var_dump($names);
    		//print_r(array_values($names));
    	?>
    #167030

    In reply to: Chosen filters


    Anonymous
    Inactive

    Thanks this code is doing the job for me:

    <?php
    
    	global $searchandfilter;
    	$sf_current_query = $searchandfilter->get(3301)->current_query()->get_array();
    	foreach ($sf_current_query as $key => $value) {
    
    			$type = $value['type'];
    			$valuei = $value['active_terms'][0]['value'];
    			$valuei1 = $value['active_terms'][1]['value'];
    			$name = $value['active_terms'][0]['name'];
    			$name1 = $value['active_terms'][1]['name'];
    
    			if ($key == '_sft_category') {
    				if ($name1 == NULL) {
    					echo '<button id="'.$key.'" class="but'.$type.'">';
    					echo $name;
    					echo '</button>';
    				} else {
    					echo '<button id="'.$key.'" class="but'.$type.'">';
    					echo $name;
    					echo '</button>';
    					echo '<button id="'.$key.'" class="but'.$type.'">';
    					echo $name1;
    					echo '</button>';
    				}
    			}
    
    			if ($key == '_sft_materiaalsoorten') {
    					echo '<button id="'.$key.'" class="but'.$type.'">';
    					echo $name;
    					echo '</button>';
    			}
    
    			if ($key == '_sfm_prijsklasse') {
    				if ($valuei == 0) {
    					echo '';
    				} else {
    					echo '<button id="'.$key.'" class="but'.$type.'">';
    					echo 'Prijsklasse: ';
    					echo $name;
    					echo ' vanaf';
    					echo '</button>';
    				}
    
    				if ($valuei1 == 50000) {
    					echo '';
    				} else {
    					echo '<button id="'.$key.'" class="but'.$type.'">';
    					echo 'Prijsklasse: ';
    					echo $name1;
    					echo ' tot';
    					echo '</button>';
    				}
    			}
    
    			if ($key == '_sfm_vrije_valhoogte') {
    				if ($valuei == 0) {
    					echo '';
    				} else {
    					echo '<button id="'.$key.'" class="but'.$type.'">';
    					echo 'Valhoogte: ';
    					echo $name;
    					echo ' vanaf';
    					echo '</button>';
    				}
    
    				if ($valuei1 == 300) {
    					echo '';
    				} else {
    					echo '<button id="'.$key.'" class="but'.$type.'">';
    					echo 'Valhoogte: ';
    					echo $name1;
    					echo ' tot';
    					echo '</button>';
    				}
    			}
    
    			if ($key == '_sfm_beschikbare_obstakelvrije_ruimte') {
    				if ($valuei == 0) {
    					echo '';
    				} else {
    					echo '<button id="'.$key.'" class="but'.$type.'">';
    					echo 'Beschikbare obstakelvrije ruimte: ';
    					echo $name;
    					echo ' vanaf';
    					echo '</button>';
    				}
    
    				if ($valuei1 == 350) {
    					echo '';
    				} else {
    					echo '<button id="'.$key.'" class="but'.$type.'">';
    					echo 'Beschikbare obstakelvrije ruimte: ';
    					echo $name1;
    					echo ' tot';
    					echo '</button>';
    				}
    			}
    
    			if ($key == '_sfm_leeftijdsindicatie_van') {
    				if ($valuei == 0) {
    					echo '';
    				} else {
    					echo '<button id="'.$key.'" class="but'.$type.'">';
    					echo 'Leeftijdsindicatie: vanaf ';
    					echo $name;
    					echo '</button>';
    				}
    
    				if ($valuei1 == 20) {
    					echo '';
    				} else {
    					echo '<button id="'.$key.'" class="but'.$type.'">';
    					echo 'Leeftijdsindicatie: tot ';
    					echo $name1;
    					echo '</button>';
    				}
    			}
    
    	}
    ?>

    But what now? How can I make it when somebody clicks on a button the filter turns off?

    #166837

    In reply to: Chosen filters


    Anonymous
    Inactive

    Thanks Trevor. I’m pretty new to PHP so I hope you dont mind me asking questions.

    I got this code:

    global $searchandfilter;
    $sf_current_query = $searchandfilter->get(3301)->current_query()->get_array();
    foreach($sf_current_query as $key) {
    
    	$type = $key['type'];
    	$name = $key['active_terms'][0]['name'];
    	$name1 = $key['active_terms'][1]['name'];
    
    	echo '<button class="' . $type . '">';
    	echo $name;
    	if ($name1 == NULL) {
    	} else {
    		echo ' - ';
    		echo $name1;
    	}
    	echo '</button>';
    
    }

    I want the id of the button to be the array name.
    Like: <button id="_sfm_prijsklasse" class="post_meta">
    <button id="_sft_category" class="taxonomy">

    How can I do this?

Viewing 10 results - 11 through 20 (of 45 total)