Skip to content

Instantly share code, notes, and snippets.

@gterrill
Created August 19, 2010 05:08
Show Gist options
  • Save gterrill/537099 to your computer and use it in GitHub Desktop.
Save gterrill/537099 to your computer and use it in GitHub Desktop.
{% comment %}
You can use this snippet to display categories on the front page. Turn on this snippet using theme settings.
{% endcomment %}
{% if linklists.categories.links.size > 0 %}
<div id="products">
{% for link in linklists.categories.links %}
<div class="product {% cycle 'first_col', '', '', 'last_col' %}">
{% assign collection = link.object %}
{% if collection.products.size > 0 %}
{% assign product = collection.products.first %}
<div class="image">
<a href="{{ collection.url }}" title="{{ collection.title | escape }}">
<img src="{{ product.images.first | product_img_url: 'compact' }}" alt="{{ collection.title | escape }}"/>
</a>
</div>
<div class="info">
<div class="title ellipsis"><a href="{{ collection.url }}">{{ collection.title | escape }}</a></div>
</div>
{% endif %}
</div>
{% endfor %}
</div>
{% else %}
<p class="instructions">To view a category listing, <a href="/admin/links">create a link list</a> name "Categories", and insert links to your category collections.</p>
{% endif %}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment