just the url for link_to_add_tag

kanarick
Shopify Partner
28 0 3

 

What I want to do is create a checkbox list of tags for a collection instead of a <ul>

The code I have is this:

 

<form>
{% for tag in collection.tags %}
  {% if current_tags contains tag %}
  <input type="checkbox" checked onclick="window.location='xxx'"; return true;">{{ tag | link_to_remove_tag: tag }}<br>
   {% else %}
   <input type="checkbox"  onclick="window.location='xxx'"; return true;">{{ tag | link_to_add_tag: tag }}<br>
   {% endif %}
{% endfor }
</form>

 

My question is this: what should I replace the 'xxx' with?

I would have assumed that I could use link_to_add_tag but that only returns a fully-formed <a href="foo" title="bar"> link, which obviously won't work.

Any help would be greatly appreciated.

 

-- cmk

 

 

Replies 4 (4)
spicydesign
Shopify Expert
313 0 8

Try this

{{ shop.url }}{{ collection.url}}/{{ tag | handleize }}

www.spicydesign.ca  http://experts.shopify.com/spicydesign
kanarick
Shopify Partner
28 0 3

That helps me get the URL for the tag alone, but it doesn't help me add or remove tags from a URL.

 

 

kanarick
Shopify Partner
28 0 3

ok, i figured it out. spicy, your code didn't work, it needed to be

 

{{ tag | replace: ' ', '-' | downcase }}

I didn't have any special characters in my tags, so that works well.

 

Then I wrote a replacement in javascript for link_to_remove_tag and link_to_add_tag using simple string searches + substitutions along with redirects.

I'll post the full code soon

 

Atiqur_Rahman
Shopify Partner
17 1 16

 

{{ shop.secure_url }}/collections/{{collection.handle}}/{{ tag }}+{{ current_tags | join: '+' }}

 

 

Use the code above. It'll print the url of the  tag only.

If you have any requirement, please email me directly to ratiqur807@gmail.com

I'm the GENUINE EXPERT that you might need today!