Difference between revisions of "Liquid Template Variables - current tags"

From Spiffy Stores Knowledge Base

(New page: The '''current_tags''' of a collection are the tags that have been used to filter the current view of the collection. For example, with the URL: <pre>/page /collections/hair_raising_stuf...)
 
m
 
(One intermediate revision by the same user not shown)
Line 1: Line 1:
The '''current_tags''' of a collection are the tags that have been used to filter the current view of the collection.
+
The '''current_tags''' of a collection are the tags that have been used to filter the current view of the collection.  
 +
 
 +
'''current_tags''' is always returned as an array of tag values. If there aren't any tags, then a null value is returned.
 +
 
 +
The array can be tested by
 +
 
 +
<pre>
 +
  {% if current_tags %}
 +
    ...
 +
  {% endif %}
 +
</pre>
  
 
For example, with the URL:
 
For example, with the URL:
Line 5: Line 15:
 
<pre>/page /collections/hair_raising_stuff/lime+electric+unforgettable</pre>
 
<pre>/page /collections/hair_raising_stuff/lime+electric+unforgettable</pre>
  
In this case, '''current_tags''' will be ''"lime,electric,unforgettable"''.
+
In this case, '''current_tags''' will be ''["lime", "electric", "unforgettable"]''.
  
 
There may be additional tags which can be accessed using '''collection.tags'''.
 
There may be additional tags which can be accessed using '''collection.tags'''.

Latest revision as of 22:26, 27 April 2016

The current_tags of a collection are the tags that have been used to filter the current view of the collection.

current_tags is always returned as an array of tag values. If there aren't any tags, then a null value is returned.

The array can be tested by

  {% if current_tags %}
    ...
  {% endif %}

For example, with the URL:

/page /collections/hair_raising_stuff/lime+electric+unforgettable

In this case, current_tags will be ["lime", "electric", "unforgettable"].

There may be additional tags which can be accessed using collection.tags.