Last active
December 11, 2015 11:38
-
-
Save brianweiner/4595339 to your computer and use it in GitHub Desktop.
subsection of search-filter-partial for category behavior
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!-- FIND CATEGORY --> | |
{% if selected_categories is defined %} | |
{% set current_category = method('Extensions320ny_Shop_Category', 'create').find_by_id(selected_categories[0]) %} | |
{% else %} | |
{% set current_category = category ? category : product.list_categories[0] %} | |
{% endif %} | |
<form id="search-filter" method="get" action="/search"> | |
<input type="hidden" name="query" value="{{ query ? query: '' }}"> | |
<!-- CATEGORIES --> | |
{% set categories = method('Shop_Category', 'create').list_root_children('front_end_sort_order') %} | |
{% set selected_categories = selected_categories ? selected_categories : [] %} | |
{% if categories.count %} | |
{{ category ? "" : "<h4>Departments</h4>"}} | |
<select id="category-select" style="display:none;" {{category ? '':"multiple" }} name="categories[]"> | |
{% for category in categories %} | |
<option | |
{{ category.id in selected_categories ? 'selected="selected"' : null }} | |
{{ category.id == current_category.id ? 'selected="selected"' : null }} | |
value="{{ category.id }}">{{ category.name }}</option> | |
{% endfor %} | |
</select> | |
{% if category == null %} | |
{% for category in categories %} | |
<span data-select="category-select" data-value="{{category.id}}" data-type="category" | |
{{ category.id in selected_categories ? 'class="category-filter filter-option search-filter-selection"' : 'class="category-filter filter-option"' }} | |
>{{category.name}}</span> | |
{% endfor %} | |
<br><br> | |
{% endif %} | |
{% endif %} | |
{% set my_cat = method('Extensions320ny_Shop_Category', 'create').find_by_id(current_category.id) %} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment