I have a supersearch form with checkbox filters for a custom field. The results are working great and the url looks like this: /search&amenities=dryer&&dvd&&fireplace/

Now I'm trying to set the conditionals to make the active checkbox checked. Following the docs here's what I've tried:

{if super_search_amenities_dvd}checked="checked"{/if}/>

The && at the end of the value are made to chain more than one filter (dryer&&dvd). I also tried

{if super_search_amenities_dvd&&}checked="checked"{/if} 

but it doesn't work. Any ideas? How can I make this conditional work?

Thanks in advance! S-

2 Answers 2


If you're using EE 2.9+ maybe try the new "contains" conditional:

{if super_search_amenities *= 'dvd'}checked{/if}

Could probably check against the entire last_segment if you prefer.


Super Search's {super_search_FIELD_checkboxvalue} was made with OR searches in mind (not AND searches). Using && in fact throws a PHP error as Super Search can't read something like {super_search_amenities_dvd&&} properly.

However, {super_search_amenities} should output dryer&&dvd&&fireplace, which means you could break up this string using PHP and use the individual values in conditionals to output your checked="checked" string.

First, turn on PHP for your template and set it to Output.

Then, break up the string into an array of individual categories:

<?php $items = explode("&&", '{super_search_amenities}'); ?>

Next, for each checkbox field, loop through each item in the array and use a conditional to check if there's a match with your checkbox field value:

<?php foreach($items as $item) :?>
    <?php if($item == 'dvd') :?>
    <?php endif ?>
<?php endforeach ?>

Repeat for each checkbox.

Perhaps too lengthly? PHP has more than one way to deal with data. You could instead create an array of your checked values and check if each checkbox field item is in this array. Starting from the top:

<?php $items = explode("&&", '{super_search_amenities}'); /* --Break up the Super Search string-- */ ?>

<?php $item_array = array(); /* --Start with an empty array-- */ ?>

<?php if(count($items) > 0) :?>
    <?php foreach($items as $item) :?>
        <?php $item_array[] = $item; /* --Adding checked items to the array-- */ ?>
    <?php endforeach ?>
<?php endif ?>

     The array is now built. 
     Now go through your checkbox fields, and with a single line
     check if each value is in $item_array, eg. : 

<input type="checkbox" name="amenities[]" value="dvd&&" 
   <?php if( in_array('dvd', $item_array) ) :?>checked="checked"<?php endif ?>

Repeat for each checkbox.

Based on the solution for breaking up category values found here: http://support.solspace.com/solution/categories/115922/folders/257413/articles/184200-handling-searches-with-multiple-categories-or-multiple-values-for-a-custom-field-i-e-an-array-of-se , and modified for this answer.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.