Skip to content

Instantly share code, notes, and snippets.

@iainurquhart
Created December 19, 2014 09:49
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save iainurquhart/c6570823898965fcd1c1 to your computer and use it in GitHub Desktop.
Save iainurquhart/c6570823898965fcd1c1 to your computer and use it in GitHub Desktop.
{% extends "_layout" %}
{% set title = "Catalogue" %}
{% set navItems = craft.facetedNav.getNav(['plants', 'sun', 'soil']) %}
{% set relatedTo = '' %}
{% set params = {section: 'catalogue'} %}
{% block content %}
<section class="list-products">
{# do we have any current filters, if so show tag UI #}
{% if navItems.activeCategories|length %}
<nav class="filter-crumbs">
<h3>Browsing items filed under:</h3>
{% set relatedTo = ['and'] %}
{# list our current active categories #}
{% for category in navItems.activeCategories %}
<a href="{{ url('catalogue'~category.url.remove) }}" title="Remove this filter">{{ category.title }} <span>&times;</span></a>
{# build our relatedTo array #}
{% set relatedTo = relatedTo|merge([category.model]) %}
{% endfor %}
{# final prep for relatedTo before it goes to entries() #}
{% set params = params|merge({relatedTo: relatedTo}) %}
</nav>
{% endif %}
{% paginate craft.entries(params).limit(12) as entries %}
{% for entry in entries %}
<article>
<a href="{{ entry.url }}">
<h2>{{ entry.title }}</h2>
...
</a>
</article>
{% endfor %}
{% if entries | length == 0 %}
<p class="notification no-results"><strong>Sorry, we don't have any results for the criteria you specified. </strong>
<br />Try removing some filters to broaden your search.</p>
{% endif %}
{% include '_partials/_pagination' %}
{% endpaginate %}
</section>
<aside class="sidebar sidebar--secondary">
<nav class="subnav">
{% for catGroup in navItems.categoryGroups %}
<h4>{{ catGroup.name }}</h4>
<ul>
{% for cat in attribute(navItems.categories, catGroup.handle) %}
<li{% if cat.active %} class="active"{% endif %}>
<a href="{{ url('catalogue'~cat.url.add) }}" class="add">{{ cat.title}}</a>
{% if cat.active %} <a href="{{ url('catalogue'~cat.url.remove) }}" class="remove" title="Remove this filter">&times;</a> {% endif %}
</li>
{% endfor %}
</ul>
{% endfor %}
</nav>
</aside>
</div>
{% endblock %}
Copy link

ghost commented Jul 12, 2015

cms

Copy link

ghost commented Jul 27, 2015

craft

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment