Forums › Forums › Search & Filter Pro › I need to output taxonomy terms separated by comma
Tagged: output, taxonomy terms
- This topic has 5 replies, 2 voices, and was last updated 9 years, 2 months ago by Anonymous.
-
Anonymous(Private) October 2, 2015 at 2:45 pm #26393
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-changewhen 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!
– NinaRoss Moderator(Private) October 5, 2015 at 9:28 pm #26581Hi 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(Private) October 7, 2015 at 4:42 am #26674Hello 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%2CmotivationSorry for being dense. As I said I’m a beginner.
Really need your help with this critical project.Thank you again, Nina
Ross Moderator(Private) October 7, 2015 at 6:40 pm #26753Hi 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 fieldThanks
Anonymous(Private) October 7, 2015 at 11:46 pm #26784Thank you again Ross!
Getting really closer to desired output.
I was able to output results. I did not want to show All when nothing is selected for one of the fields,
so I changed “show_all_if_empty” => falseWhat still does not work for me is “delim is the delimiter between the actual options selected within a field” – options continue to come glued together.
Here is an example of two options chosen for each of two fields:
Leadership: CommunicationLeading Change
Governance: AccountabilityStewardship of ResourcesThank you for your continued guidance!
Nina -
AuthorPosts