<p>Well, would this be what you are looking for? - <a href="https://github.com/iainurquhart/FacetedNav_CraftPlugin" rel="nofollow">https://github.com/iainurquhart/FacetedNav_CraftPlugin</a></p>

CC BY-SA 3.0
2015-06-24T19:16:01.000Z
Might possibly work! Will give it a bash tomorrow.
Jason Mayo
CC BY-SA 3.0
2015-06-26T14:05:08.693Z
This worked, but I couldn't get it to work as a *form*. I managed to dig a bit deeper in to stack exchange and found a few related posts and learnt from them to create some code that worked well. Will post shortly.
Jason Mayo
CC BY-SA 4.0
2019-04-17T11:24:28.423Z
@JasonMayo can you please share related to search form as i stuck there.
inrsaurabh
CC BY-SA 4.0
2019-04-26T10:57:13.350Z
@inrsaurabh See that accepted answer (Mine). I think that's what your asking for?
Jason Mayo
CC BY-SA 3.0
2015-06-24T19:02:21.797Z
2015-06-24T19:02:21.797Z
John
<p>I managed to figure this out by looking through a few other posts:</p>

<ul>
<li><a href="https://craftcms.stackexchange.com/questions/1878/advanced-search">Advanced Search</a></li>
<li><a href="https://craftcms.stackexchange.com/questions/6837/building-a-simple-search-by-multiple-categories?rq=1">Building a simple search by multiple categories</a></li>
<li><a href="https://craftcms.stackexchange.com/questions/4571/building-results-from-advanced-search-form?rq=1">Building Results From Advanced Search Form</a></li>
<li><a href="https://craftcms.stackexchange.com/questions/9081/how-to-filter-entries-by-clicking-multiple-categories-on-front-end?rq=1">How to filter entries by clicking multiple categories on front end</a></li>
<li><a href="https://craftcms.stackexchange.com/questions/2086/fetching-entries-from-an-advanced-search-form-on-the-front-end?rq=1">Fetching entries from an advanced search form on the front end</a></li>
</ul>

<p>Which I then took their knowledge and put together my own form and results template. With the results I wanted the same code &amp; template to be used for search results AND the general "knowledge" page.</p>

<p><strong>Filter Form</strong></p>

<pre><code>&lt;form action="{{ url('knowledge') }}"&gt;

    &lt;ul&gt;

        {% set categoryEntries = craft.entries.limit(null) %}

        {% for category in craft.categories.group('knowledge') %}

            {% set categoriesEntryCount = categoryEntries.relatedTo(category).total() %}

            &lt;li&gt;
              &lt;input type="checkbox" name="category[]" value="{{ category.slug }}" id="{{ category.slug }}"&gt;
              &lt;label for="{{ category.slug }}"&gt;{{ category.title }} ({{ categoriesEntryCount }})&lt;/label&gt;
            &lt;/li&gt;

        {% endfor %}

    &lt;/ul&gt;

&lt;/form&gt;
</code></pre>

<p><strong>Results</strong></p>

<pre><code>    {% set parameters =
        {
            section: 'channelKnowledge',
            limit: '1'
        }
    %}

    {% set categoryQuery = craft.request.getParam('category') %}

    {% if categoryQuery %}
        {% set categoryQueryCategories = craft.categories.group('knowledge').slug(categoryQuery) %}
        {% set entries = craft.entries(parameters).relatedTo(categoryQueryCategories).order('score') %}
    {% else %}
        {% set entries = craft.entries(parameters) %}
    {% endif %}

    {% paginate entries as channelKnowledgeEntries %}

    {% if entries|length %}

        {% for entry in channelKnowledgeEntries %}

            {{ entry.title }}

        {% endfor %}

    {% else %}

        &lt;p&gt;No Results&lt;/p&gt;

    {% endif %}

    {% if paginate %}

        &lt;div class="pagination"&gt;
            {% if paginate.prevUrl %}
                &lt;span&gt;
                    &lt;a href="{{ paginate.prevUrl }}" class="back"&gt;Previous&lt;/a&gt;
                &lt;/span&gt;
            {% endif %}
            &lt;ul&gt;
                {% for page, url in paginate.getPrevUrls(5) %}
                    &lt;li&gt;
                        &lt;a href="{{ url }}"&gt;{{ page }}&lt;/a&gt;
                    &lt;/li&gt;
                {% endfor %}
                &lt;li&gt;
                    &lt;a href="" class="active"&gt;
                        {{ paginate.currentPage }}
                    &lt;/a&gt;
                &lt;/li&gt;
                {% for page, url in paginate.getNextUrls(5) %}
                    &lt;li&gt;
                        &lt;a href="{{ url }}"&gt;{{ page }}&lt;/a&gt;
                    &lt;/li&gt;
                {% endfor %}
            &lt;/ul&gt;
            {% if paginate.nextUrl %}
                &lt;span&gt;
                    &lt;a href="{{ paginate.nextUrl }}" class="forward"&gt;Next&lt;/a&gt;
                &lt;/span&gt;
            {% endif %}
        &lt;/div&gt;

    {% endif %}

{% endpaginate %}
</code></pre>

CC BY-SA 3.0
2015-06-26T14:49:09.303Z
2015-06-26T14:49:09.303Z
2017-04-13T12:51:00.303Z
Jason Mayo
<p>Previously on EE I've used Low Search to generate a filter based search form, based on categories. But with Craft I can't seem to find an add-on - Or even know if I need one!</p>

<p>What I'm trying to achieve is a filer menu with categories e.g.:</p>

<pre><code>[ ] Category 1
[x] Category 2
[ ] Category 3
[x] Category 4
   [ ] Category 4.1
   [ ] Category 4.2
[ ] Category 5
</code></pre>

<p>I've been reading over the documentation over at:</p>

<p><a href="https://craftcms.com/docs/searching" rel="nofollow noreferrer">https://craftcms.com/docs/searching</a> and <a href="https://craftcms.com/docs/templating/search-form" rel="nofollow noreferrer">https://craftcms.com/docs/templating/search-form</a></p>

<p>But I'm struggling to see how I can make this work within a search form itself. </p>

<p>I'm thinking I can generate a query fine to search the categories. But I can't work out how to link what is checked with a query.</p>

<p>Any help would be gooooood :)</p>

<search>
Filter based Search Form
# Filter based Search Form

(Asked by: username_0 on 2015-06-24)

Previously on EE I've used Low Search to generate a filter based search form, based on categories. But with Craft I can't seem to find an add-on - Or even know if I need one!
What I'm trying to achieve is a filer menu with categories e.g.:
[ ] Category 1
[x] Category 2
[ ] Category 3
[x] Category 4
   [ ] Category 4.1
   [ ] Category 4.2
[ ] Category 5

I've been reading over the documentation over at:
https://craftcms.com/docs/searching and https://craftcms.com/docs/templating/search-form
But I'm struggling to see how I can make this work within a search form itself. 
I'm thinking I can generate a query fine to search the categories. But I can't work out how to link what is checked with a query.
Any help would be gooooood :)

**Tags:** search

---

## 2 answers

### Answer by username_0 on 2015-06-26. Score: 9 | Accepted answer

I managed to figure this out by looking through a few other posts:

Advanced Search
Building a simple search by multiple categories
Building Results From Advanced Search Form
How to filter entries by clicking multiple categories on front end
Fetching entries from an advanced search form on the front end

Which I then took their knowledge and put together my own form and results template. With the results I wanted the same code & template to be used for search results AND the general "knowledge" page.
Filter Form


    

        {% set categoryEntries = craft.entries.limit(null) %}

        {% for category in craft.categories.group('knowledge') %}

            {% set categoriesEntryCount = categoryEntries.relatedTo(category).total() %}

            
              
              {{ category.title }} ({{ categoriesEntryCount }})
            

        {% endfor %}

    



Results
    {% set parameters =
        {
            section: 'channelKnowledge',
            limit: '1'
        }
    %}

    {% set categoryQuery = craft.request.getParam('category') %}

    {% if categoryQuery %}
        {% set categoryQueryCategories = craft.categories.group('knowledge').slug(categoryQuery) %}
        {% set entries = craft.entries(parameters).relatedTo(categoryQueryCategories).order('score') %}
    {% else %}
        {% set entries = craft.entries(parameters) %}
    {% endif %}

    {% paginate entries as channelKnowledgeEntries %}

    {% if entries|length %}

        {% for entry in channelKnowledgeEntries %}

            {{ entry.title }}

        {% endfor %}

    {% else %}

        No Results

    {% endif %}

    {% if paginate %}

        
            {% if paginate.prevUrl %}
                
                    Previous
                
            {% endif %}
            
                {% for page, url in paginate.getPrevUrls(5) %}
                    
                        {{ page }}
                    
                {% endfor %}
                
                    
                        {{ paginate.currentPage }}
                    
                
                {% for page, url in paginate.getNextUrls(5) %}
                    
                        {{ page }}
                    
                {% endfor %}
            
            {% if paginate.nextUrl %}
                
                    Next
                
            {% endif %}
        

    {% endif %}

{% endpaginate %}


---

### Answer by username_1 on 2015-06-24. Score: 3

Well, would this be what you are looking for? - <https://github.com/iainurquhart/FacetedNav_CraftPlugin>

> **Comments:**
> **username_0**: Might possibly work! Will give it a bash tomorrow.  
> **username_0**: This worked, but I couldn't get it to work as a *form*. I managed to dig a bit deeper in to stack exchange and found a few related posts and learnt from them to create some code that worked well. Will post shortly.  
> **username_2**: @JasonMayo can you please share related to search form as i stuck there.  
> **username_0**: @inrsaurabh See that accepted answer (Mine). I think that's what your asking for?  

---

