2

I've been trying to build a category filter. I managed to make my buttons respond with categories but the returned entries on the page stay the same. So when I click one of the links "/?category=koop" gets added to the URL, but my entries don't respond upon that URL. I do have added the categories in the CP and assigned them to my entries.

Here is the code of my filters:

{% if craft.request.getParam('offerCategory') is not null %}

    {% set offerCategory = craft.categories.slug(craft.request.getParam('offerCategory')) %}
    {% set offers = craft.entries.section('offers').relatedTo(offerCategory).find() %}

{% else %}

    {% set offers = craft.entries.section('offers').find() %}

{% endif %}

And my button list

{% for offerCategory in craft.categories.group('offerTypes').find() %}
    <li>
        <a class="mart-button" href="{{craft.request.url}}/?category={{ offerCategory.slug }}">{{ offerCategory.title }}</a>
    </li>
{% endfor %}

I'm quite new to Craft. One of the resources I'm using to build this is: http://craftcookbook.net/recipes/197.

If anyone knows what I'm overseeing, thanks in advance.

3

I suggest changing the couple places where you use getParam('offerCategory') to getParam('category') so it matches the parameter set in the URL.

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.