I have a page where by default it lists all of the entries inside the section 'work'. I'd like to have a secondary menu where I can filter these entries by the field 'projectCategories'.
{% for entry in craft.entries.section('work').find() %}
<li class="wp-project">
{% for asset in entry.mainProjectImage %}
<a href="{{ entry.url }}" class="project-link">
<img src="{{ asset.getUrl('workPageImage')}}" alt="{{ asset.title }}" />
</a>
{% endfor %}
<p class="project-title">{{ entry.title }}</p>
<p class="project-categories">
{% for option in entry.projectCategories %}
{% if loop.last %}
{{ option }}
{% else %}
{{ option }} +
{% endif %}
{% endfor %}
</p>
</li>
{% endfor %}
My current solution is a secondary menu above the entries that links to a url where it filters the entry for just for that project category with:
{% for entry in craft.entries.section('work').search('projectCategories:Packaging') %}
This works but isn't DRY and unfortunately because of AJAX the secondary menu fades out and back in again when you change the URL.
Is there a way to filter entries by a field without changing the url? Or alternatively is there a way of making the secondary menu not reload with AJAX when on a url that begins with 'work'?
work
url, are you showing me all of the work by default? For example, if I choose a filter, is the system hiding all irrelevant entries that don't belong to the chosen filter? Or, are you needing to request new entires for any given filter?