-
AuthorSearch Results
-
May 13, 2017 at 2:49 pm #108628
In reply to: How to show the currently selected title only
AnonymousInactiveHi Trevor,
UPDATE! I’ve managed to half get it working!!!
It now works for all categories except the “All Categories” one, this seems to behave differently to the others and the code I have used doesn’t bring it in:
$sf_current_query = $searchandfilter->get(766)->current_query()->get_array(); echo $sf_current_query['_sft_category']['active_terms'][0]['name'];
I’ve left the printr statement in on the live site so you can get a picture of what is happening. I presume there may need to be an if statement added but I have yet to be able to pull in the “All categories” heading… I was however thinking of just hard coding a title in as it is only one title?? But i’m not sure how I would do it. I’m sure there is a “proper” fix to this though?
I hope you have a good weekend
May 12, 2017 at 4:08 pm #108514In reply to: How to show the currently selected title only
TrevorParticipantYou tried this?
<?php global $searchandfilter; $sf_current_query = $searchandfilter->get(504)->current_query()->get_array(); echo '<pre>',print_r($sf_current_query),'</pre>'; ?>
May 12, 2017 at 2:44 pm #108481In reply to: How to show the currently selected title only
TrevorParticipantAh, I see the erro. Not sure how many steps back you will need to take though.
$sf_current_query = $searchandfilter->get(504)->current_query()->get_array();
And look at what is in THAT array using print_r.
May 12, 2017 at 2:00 pm #108461In reply to: How to show the currently selected title only
TrevorParticipantTry this then:
<?php global $searchandfilter; $sf_current_query = $searchandfilter->get(504)->current_query(); echo $sf_current_query['_sft_category'][0]['taxonomy_name']; ?>
May 12, 2017 at 11:41 am #108447In reply to: How to show the currently selected title only
AnonymousInactive<?php global $searchandfilter; $sf_current_query = $searchandfilter->get(504)->current_query(); echo $sf_current_query['_sft_category']['taxonomy_name']; ?>
This code gives me an error… although it does look like this should work?
May 12, 2017 at 11:24 am #108444In reply to: How to show the currently selected title only
TrevorParticipantIf you echo this:
$sf_current_query['_sft_category']['taxonomy_name']
What does it give you?
May 12, 2017 at 11:00 am #108431In reply to: How to show the currently selected title only
AnonymousInactiveOkay, I have used the following code to display the array:
<?php echo '<pre>',print_r($sf_current_query),'</pre>';?>
This displays the following:
Search_Filter_Active_Query Object ( [sfid] => 504 [is_set:Search_Filter_Active_Query:private] => 1 [query_array:Search_Filter_Active_Query:private] => Array ( ) [form_fields:Search_Filter_Active_Query:private] => Array ( [_sft_category] => Array ( [type] => category [input_type] => radio [heading] => Categories [accessibility_label] => [all_items_label] => All Articles [show_count] => 1 [hide_empty] => 1 [hierarchical] => 0 [include_children] => 1 [drill_down] => 0 [sync_include_exclude] => 1 [combo_box] => 0 [operator] => or [order_by] => default [order_dir] => asc [exclude_ids] => [taxonomy_name] => category ) )
(plus lots more)
So what I want is the taxonomy name field but I have no idea how to access this field and echo into my template? Any help here would be much appreciated, I understand this may be out of the scope of support but if it’s something simple that you might know you could really help me out a lot.
Thanks
May 12, 2017 at 12:19 am #108367In reply to: How to show the currently selected title only
TrevorParticipantYou would need to dig deeper in the
$sf_current_query
array I suspect. You can echo the array to a page with a PHP print_r function inside pre tags.May 11, 2017 at 7:24 pm #108331In reply to: How to show the currently selected title only
AnonymousInactive<?php global $searchandfilter; $sf_current_query = $searchandfilter->get(504)->current_query(); echo $sf_current_query->get_field_string("_sft_category"); ?>
The above code gets the current category, but how to do it without the extraneous word(s) before it?
Thanks
April 26, 2017 at 7:04 pm #105034In reply to: visibility of reset button
TrevorParticipantHi
You could use PHP to see if the results are filtered, like this (change the ID number for yours):
global $searchandfilter; $sf_current_query = $searchandfilter->get(1234)->current_query(); if (($sf_current_query->is_filtered())||($sf_current_query->get_search_term()!="")) { // do something that identifies a search has been made (set some CSS, ...) } // your normal template code here
-
AuthorSearch Results