Skip to content

Instantly share code, notes, and snippets.

@j7u7l7s
Created January 9, 2018 09:49
Show Gist options
  • Save j7u7l7s/6d16f468d9b9a5e8454f17068a3279d8 to your computer and use it in GitHub Desktop.
Save j7u7l7s/6d16f468d9b9a5e8454f17068a3279d8 to your computer and use it in GitHub Desktop.
A small customisation on the the turbo themes search function
{% comment %} Custom Search in Turbo Theme - Excludes untagged products {% endcomment %}
{% assign product_found = false %}
{% assign skip = false %}
{% assign collection_group = products | map: 'id' %}
{% assign collection_group_thumb = collection_group | append : 'thumb' %}
{% assign collection_group_mobile = collection_group | append : 'mobile' %}
{% capture new_row %}
<br class="clear product_clear" />
{% endcapture %}
<div itemtype="http://schema.org/ItemList" class="product-list collection-matrix clearfix">
{% for product in products limit: limit %}
{% comment %} The next five lines exclude untagged products from search {% endcomment%}
{% if search.performed %}
{% if product.tags == blank %}
{% assign skip = true %}
{% endif %}
{% endif %}
{% if product.id == skip_product.id or skip == true %}
{% assign product_found = true %}
{% else %}
{% if forloop.rindex0 == 0 and product_found == false and forloop.length != products.count and template != 'search' and template != 'index' %}
{% assign skip = true %}
{% else %}
{% include 'product-thumbnail', sidebar: sidebar %}
{% if products_per_row == 2 %}
{% cycle collection_group: '', new_row %}
{% elsif products_per_row == 3 %}
{% cycle collection_group: '', '', new_row %}
{% elsif products_per_row == 4 %}
{% cycle collection_group: '', '', '', new_row %}
{% elsif products_per_row == 5 %}
{% cycle collection_group: '', '', '', '', new_row %}
{% elsif products_per_row == 6 %}
{% cycle collection_group: '', '', '', '', '', new_row %}
{% elsif products_per_row == 7 %}
{% cycle collection_group: '', '', '', '', '', '', new_row %}
{% endif %}
{% endif %}
{% endif %}
{% endfor %}
{% if settings.pagination_type == 'load_more' or settings.pagination_type == 'infinite_scroll' and template contains 'collection' %}
{% if paginate.next.url %}
<div class="js-load-more load-more">
<a href="{{ paginate.next.url }}" data-no-instant class="load-more__btn action_button continue-button">{{ 'collections.general.load_more' | t }}</a>
</div>
{% endif %}
{% endif %}
</div>
<div class="load-more__icon"></div>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment