d
Topic
capercreative Member
Posts:
1
Last edited February 29, 2012

Only one Tag at a time This post is outdated

Hello all,

I'm using this theme http://react-graphite.myshopify.com/collections/frontpage?constraint=black

When you select a tag across the top it filters the product, if you select a second tag it adds it to the initial selection and filters it more.

 

I want it to only select one tag at a time.

Selecting a new tag will deselect the previous selection.

 

I've found this code but unsure what to do about it, i tried a few things to no avail.

 

<div class="tags">
    <ul class="clearfix">
          <li{% unless current_tags %} class="active"{% endunless %}><a href="{{ blog.url }}">All</a>
          {% for tag in blog.all_tags %}
          {% if current_tags contains tag %}
          <li class="active">{{ tag | link_to_remove_tag: tag }}</li>
          {% else %}
          <li>{{ tag | link_to_add_tag: tag }}</li>
          {% endif %}
          {% endfor %}
    </ul>
</div> <!-- /.tags -->

i
Replies
stace Shopify Merchant whoswhointhezoo.com
Posts:
6
March 14, 2012

You simply have to remove one word - take out 'add' in <li> - see below:

 

<div class="tags">
    <ul class="clearfix">
          <li{% unless current_tags %} class="active"{% endunless %}><a href="{{ blog.url }}">All</a>
          {% for tag in blog.all_tags %}
          {% if current_tags contains tag %}
          <li class="active">{{ tag | link_to_remove_tag: tag }}</li>
          {% else %}
          <li>{{ tag | link_to_tag: tag }}</li>
          {% endif %}
          {% endfor %}
    </ul>
</div> <!-- /.tags -->

Jamie Chief Officer of Funness shopify.com/plus
Posts:
5856
March 14, 2012

Stace is correct. Remove the to_add and to_remove parameters:

 

<div class="tags">
    <ul class="clearfix">
          <li{% unless current_tags %} class="active"{% endunless %}><a href="{{ blog.url }}">All</a>
          {% for tag in blog.all_tags %}
          {% if current_tags contains tag %}
          <li class="active">{{ tag | link_to_tag: tag }}</li>
          {% else %}
          <li>{{ tag | link_to_tag: tag }}</li>
          {% endif %}
          {% endfor %}
    </ul>
</div> <!-- /.tags -->

Should be able to drop that in ^

 

http://evolvedesign.co ::: http://twitter.com/bacchus

Log in or sign up for an account to reply.

f
Your Reply