0

So, I'm doing a filtration of my search results. I'm using checkboxes.

In order to get the colours I need to filter with, I loop through all the entries and run it through stash to get rid of duplicates. Then I put these values in a checkbox-input.

This works great when just looking in one custom field, but with 4 custom fields, not so much.

I can loop out everything as I'm supposed to, but the submitting value needs to be the name of the field it should search in. Meaning the name="farg[]" should be name="frg_2[]" and so on.

The colour "Yellow" can be in any/all of the customs fields, hence me having to run it through stash to get rid of duplicates.

Running supersearch 3.1.4 and EE 3.3.3. Any suggestions?

Here's the code.

        {!-- Loops out all the colours and stores in list --}
            {exp:stash:set_list name="farger" trim="yes" parse_tags="yes"}
                {exp:channel:entries search:typ="keramik" channel="produkter"}
                    {if farg != ''}
                        {stash:farger}{farg}{/stash:farger}
                    {/if}
                    {if frg_2 != ''}
                        {stash:farger}{frg_2}{/stash:farger}
                    {/if}
                    {if frg_3 != ''}
                        {stash:farger}{frg_3}{/stash:farger}
                    {/if}
                    {if frg_multi != ''}
                        {stash:farger}{frg_multi}{/stash:farger}
                    {/if}
                {/exp:channel:entries}
            {/exp:stash:set_list}

        {!-- Get list, loop out with color name, avoid duplicates --}
            <div class="filter-holder">
                <h6>Färg</h6>
                {exp:stash:get_list
                    name="farger"
                    orderby="screen_name"
                    sort="asc|desc"
                    sort_type="string|numeric"
                    unique="yes"
                    parse="start"
                }
                    <div class="filter-name">
                            <input
                            type="checkbox"
                            name="farg[]"
                            value="{farger}"
                            id="{farger}"
                            class="checkbox"
                            {if super_search_farg == '{farger}'}checked{/if}
                            />
                            <label for="{farger}"><span></span>{farger}</label>
                    </div>

                {/exp:stash:get_list}
            </div>
0

Solved it! So, once again, I'll answer my own question.

Instead of having the colours in 4 different custom fields, I put them all in one grid, with 4 fields. That way, I can do a search in the grid, and not on a specific color-field.

Boom! Magic! :) Hope this helps someone else too.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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