0

I have a page that displays all entries in a "stories" channel. Each story is categorised and I need there to be an option to filter by these categories. Here is the code I currently have:

<div class="filter-stories">
    Filter stories by:
    {exp:channel:categories channel="stories" style="linear" show_empty="no"}
        <a href="#">{category_name}</a>
    {/exp:channel:categories}
</div>

{exp:channel:entries channel="stories" dynamic="off"}
    <aricle class="story{switch='|| end'}" style="border:1px solid #000;width: 32%; float: left;">
        <img src="{story-hero}" style="width:100%;">
        <h1>{categories}{category_name}{/categories}</h1>
        <h2>{title}</h2>
        {story-text-1}
        <a href="{page_url}">read more</a>
    </aricle>
{/exp:channel:entries}

Currently the list shows all the stories - which is how I want it to be by default, but how would I go about making the filter work. Ideally I want to click one of the category name links and it will only show the stories in that category without refreshing the page (using AJAX I assume?).

I've never used AJAX in ExpressionEngine, can I add to the channel entries tag with it or is there a different way to achieve this?

Thanks in advance.

1

There's a great 2-part walkthrough of a setup like this on the Meta Q site that would be worth a read.

1
  • You're very welcome. I love it when there's a step-by-step tutorial on how to do something. Makes life so much easier! – Jean St-Amand Sep 10 '13 at 16:53

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.