d
Topic
coldclimate Shopify Partner
Posts:
5
August 19, 2011

Capturing a variable to be used to access a linklist This post is outdated

This one is baking my noodle. I'm trying to catch the name of the collection and use that to pick the right linked list for navigation but I can't get anything to work.

{{ listname }} will render to screen correctly (and it the name of a valid list), but the <ul> list does not get populated.

However, if I swap the assign for something specific, it does work.  eg {% assign foo = 'product_jam' %}

Any ideas?  How does one reuse the information captured as a variable?

 

-- the code --

{% capture listname %}{{ collection.handle | prepend: 'products_' }}{% endcapture %}
{{ listname }}

{% assign foo = listname %}

<ul>
{% for link in linklists[foo].links %}
    <li>{{ link.handle | link_to: link.url }}</li>
{% endfor %}

i
Replies
coldclimate Shopify Partner
Posts:
5
August 19, 2011

And two minutes later I solve it...

{% capture listname %}{{ collection.handle | prepend: 'products' }}{% endcapture %}

Works just fine, but you can't have underscores in the name of a linklist if you ant to loop through it.  Odd.