Skip to content

Instantly share code, notes, and snippets.

@airways
Last active August 29, 2015 14:16
Show Gist options
  • Save airways/f6baca6ea822bc25984c to your computer and use it in GitHub Desktop.
Save airways/f6baca6ea822bc25984c to your computer and use it in GitHub Desktop.
Stash comparison
<div class="section sticky_nav">
<div class="filter_nav">
<ul>
{!-- category 2 -- a post type --}
{!-- build url so far --}
{exp:stash:set name="filter_base1"}{site_url}{segment_1}{if router_blog_name != ""}/{router_blog_name}{/if}/{if router_cat1 != ""}{router_cat1}{if:else}all{/if}{/exp:stash:set}
<li class="{if router_cat2_category_url_title == ''}active{/if}"><a href="{exp:stash:filter_base1 random}/all/">All Results</a></li>
{exp:channel:categories category_group="3" style="linear"}
<li class="{if router_cat2_category_url_title == category_url_title}active{/if}"><a href="{exp:stash:filter_base1 random}/{category_url_title}/">{category_name}</a></li>
{/exp:channel:categories}
</ul>
</div>
<div>
<ul><li>
{!-- category 1 -- the actual category --}
{!-- build url so far --}
{exp:stash:set name="filter_base2"}{site_url}{segment_1}{if router_blog_name}/{router_blog_name}{/if}{/exp:stash:set}
{exp:stash:set name="filter_tail2"}{if router_cat2}/{router_cat2}{/if}{if router_tag}/{router_tag}{/if}{/exp:stash:set}
<select id="filter-category" class="filter-control">
<option value="{exp:stash:filter_base2 random}/all{exp:stash:filter_tail2 random}/" class="{if router_cat1_category_url_title == ''}active{/if}">Category</option>
{exp:channel:categories category_group="1" style="linear"}
<option value="{exp:stash:filter_base2 random}/{category_url_title}{exp:stash:filter_tail2 random}/" {if router_cat1_category_url_title == category_url_title}selected="selected"{/if}>{category_name}</option>
{/exp:channel:categories}
</select>
</li><li>
{!-- build url so far -- build on previous base URL --}
{exp:stash:set name="filter_base3"}{exp:stash:filter_base2}/{if router_cat1}{router_cat1}{if:else}all{/if}/{if router_cat2}{router_cat2}{if:else}all{/if}{/exp:stash:set}
{exp:stash:set name="filter_tail3"}{/exp:stash:set}
<select id="filter-tag" class="filter-control">
<option>Tag</option>
{exp:tag:cloud}
<option value="{exp:stash:filter_base3 random}/{exp:ce_str:ing lowercase}{tag}{/exp:ce_str:ing}/{exp:stash:filter_tail random}" {if router_tag == "{tag}"}selected="selected"{/if}>{exp:ce_str:ing ucwords htmlentities}{tag}{/exp:ce_str:ing}</option>
{/exp:tag:cloud}
</select>
</li><li>
{!-- build url so far -- build on previous base URL --}
{exp:stash:set name="filter_base4"}{exp:stash:filter_base3}/{if router_tag}{router_tag}{if:else}all{/if}{/exp:stash:set}
<select id="filter-date" class="filter-control">
<option>Date</option>
{exp:channel:month_links channel="articles|products" limit="50"}
<option value="{exp:stash:filter_base4 random}/{year}-{month_num}" {if "{router_date_year}-{router_date_month}" == "{year}-{month_num}"}selected="selected"{/if}>{year}, {month}</option>
{/exp:channel:month_links}
</select>
</li>
</ul
</div>
</div>
<div class="section sticky_nav">
<div class="filter_nav">
<ul>
<li class="{if router_cat2_category_url_title == ''}active{/if}"><a href="{site_url}{segment_1}{if router_blog_name}/{router_blog_name}{/if}/{router_cat1}/all{if router_tag}/{router_tag}{/if}{if router_date_month}/{router_date_year}-{router_date_month}{/if}">All Results</a></li>
{exp:channel:categories category_group="3" style="linear"}
<li class="{if router_cat2_category_url_title == category_url_title}active{/if}"><a href="{site_url}{segment_1}{if router_blog_name}/{router_blog_name}{/if}/{router_cat1}/{category_url_title}/">{category_name}</a></li>
{/exp:channel:categories}
</ul>
</div>
<div>
<ul><li>
<select id="filter-category" class="filter-control">
<option value="{site_url}{segment_1}{if router_blog_name}/{router_blog_name}{/if}/all/{router_cat2}/all/" class="{if router_cat1_category_url_title == ''}active{/if}">Category</option>
{exp:channel:categories category_group="1" style="linear"}
<option value="{site_url}{segment_1}{if router_blog_name}/{router_blog_name}{/if}/{category_url_title}/{router_cat2}/" {if router_cat1_category_url_title == category_url_title}selected="selected"{/if}>{category_name}</option>
{/exp:channel:categories}
</select>
</li><li>
<select id="filter-tag" class="filter-control">
<option>Tag</option>
{exp:tag:cloud}
<option value="{site_url}{segment_1}{if router_blog_name}/{router_blog_name}{/if}/{router_cat1}/{router_cat2}/{exp:ce_str:ing lowercase}{tag}{/exp:ce_str:ing}/" {if router_tag == "{tag}"}selected="selected"{/if}>{exp:ce_str:ing ucwords htmlentities}{tag}{/exp:ce_str:ing}</option>
{/exp:tag:cloud}
</select>
</li><li>
<select id="filter-date" class="filter-control">
<option>Date</option>
{exp:channel:month_links channel="articles|products" limit="50"}
<option value="{site_url}{segment_1}{if router_blog_name}/{router_blog_name}{/if}/{router_cat1}/{router_cat2}/{if "{router_tag}" != ""}{router_tag}{if:else}all{/if}/{year}-{month_num}" {if "{router_date_year}-{router_date_month}" == "{year}-{month_num}"}selected="selected"{/if}>{year}, {month}</option>
{/exp:channel:month_links}
</select>
</li>
</ul
</div>
</div>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment