AnonymousInactive
So this is kind of similar to a question I’ve already asked. But now I’m struggling with the styling of the echo.
To echo the checked boxes I use the following code:
function locaties_search() {
global $searchandfilter;
$sf_current_query = $searchandfilter->get(3403)->current_query();
return $sf_current_query->get_fields_html(array("_sft_locatie"), array('show_all_if_empty' => false));
}
add_shortcode('locatiesearch', 'locaties_search');
And then I use the following shortcode to echo the results:
<?php echo do_shortcode('[locatiesearch]'); ?>
Right now it’s displaying the results like:
Location:Location-x, Location-y
What I would like is to have it just echo like so:
Location-x
Location-y
What code should I use?
AnonymousInactive
Well, that breaks the code, the part where the echo should be doens’t show anymore. The rest doesn’t show neither.
<?php global $searchandfilter;
$sf_current_query = $searchandfilter->get(15)->current_query()->get_array();
foreach($sf_current_query as $key) {
echo '<div>' . $key['name'] . '</div>';
echo '<div>' . $key['active_terms'][0]['name'] . '</div>';
} ?>
What does this give?
global $searchandfilter;
$sf_current_query = $searchandfilter->get(339)->current_query()->get_array();
foreach($sf_current_query as $key) {
echo '<div>' . $key['name'] . '</div>';
echo '<div>' . $key['active_terms'][0]['name'] . '</div>';
}
What does this give you?
<?php
//Get a multiple fields values by passing an array of field names
//replace 1526 with the ID of your search form
global $searchandfilter;
$sf_current_query = $searchandfilter->get(15)->current_query();
print_r($sf_current_query);
?>
This?
<?php
//Get a multiple fields values by passing an array of field names
//replace 1526 with the ID of your search form
global $searchandfilter;
$sf_current_query = $searchandfilter->get(15)->current_query();
print_r($sf_current_query->get_fields_html(array(), array('show_all_if_empty' => false)));
?>
I see the error. My bad for copying and pasting. The forum has changed the quotes 🙁
<?php
//Get a multiple fields values by passing an array of field names
//replace 1526 with the ID of your search form
global $searchandfilter;
$sf_current_query = $searchandfilter->get(15)->current_query();
print_r $sf_current_query->get_fields_html(array(), array('show_all_if_empty' => false));
?>
Or, I hope that is it.
AnonymousInactive
If I use this code:
<?php
//Get a multiple fields values by passing an array of field names
//replace 1526 with the ID of your search form
global $searchandfilter;
$sf_current_query = $searchandfilter->get(15)->current_query();
print_r $sf_current_query->get_fields_html(array(), array(‘show_all_if_empty’ => false));
?>
It “breaks” the page…?
I need to see the array structure to know which element to grab. This code instead of the current echo should give the array:
print_r $sf_current_query->get_fields_html(array(), array(‘show_all_if_empty’ => false));
AnonymousInactive
<?php echo $sf_current_query->get_fields_html(array("_sft_aantal_personen","_sft_arrangementstype","_sft_type_boot","_sft_type_boot_2","_sft_boot_opties"), array('show_all_if_empty' => false)); ?>
This…
AnonymousInactive
Hi Trevor,
I think it’s this part:
<?php
//Get a multiple fields values by passing an array of field names
//replace 1526 with the ID of your search form
global $searchandfilter;
$sf_current_query = $searchandfilter->get(15)->current_query();
?>
<?php $arrangement = $sf_current_query->get_fields_html(array("_sft_aantal_personen","_sft_arrangementstype","_sft_type_boot"), array('show_all_if_empty' => false)); ?>
I like to keep my echo’s separate from the rest… so I can echo them where ever I like.