d
Topic
Posts:
150
December 29, 2007

dynamic linklists? This post is outdated

Is there a way to use a variable name instead of a static string to call a linklist? Example (doesn't work):
{% assign foo = 'my-linklist-name' %}
{% for link in linklists.foo.links %}
...do stuff...
{% endfor %}
or something like: (also doesn't work):
{% assign foo = 'my-linklist-name' %}
{% for link in linklists[foo].links %}
...do stuff...
{% endfor %}
The nested nav I'm working on for this site would be ever so much better if I could avoid doing it statically... I've tried every permutation I could think of...am I missing anything obvious here?
Matt Beck, CouldBe Studios | Portland, OR | http://www.couldbestudios.com : http://deals.couldbestudios.com
i
Replies
Posts:
734
December 29, 2007

am I missing anything obvious here?

...just a period, I think…

{% for link in linklists.[foo].links %}

see if something hatches out of that.

For the record, here are my past feature requests on this issue:

1) October 10: feature request: for linklist in linklists

2) October 11: feature request: variables in conditionals

3) October 11:feature request: link.handle

The last post contains my code for automated nested navigation (via nested linklists).

operation absurdist feature requests: terminated (http://en.wikipedia.org/wiki/Absurdism)
Posts:
150
December 30, 2007

Thanks! It’s working now.

The big issue was that I was trying to use link.title instead of link.handle…

Looking over your code sample got me thinking about that right away.

Cheers!

Matt Beck, CouldBe Studios | Portland, OR | http://www.couldbestudios.com : http://deals.couldbestudios.com
Posts:
2056
December 30, 2007

the correct syntax is without the period: {% for link in linklists[foo].links %} but liquid’s parser is so lax that it should accept just about everything.

Tobias Lütke - Shopify CEO // http://twitter.com/tobi
Posts:
734
December 31, 2007

ah. txs for correction, tobi, & for lax liquid parser :).

I was trying to use link.title instead of link.handle…

am I to infer that

1. using link.handle works?
2. therefore it exists?
3. therefore my feature request has been satisfied?

can that be, tobi?!!?

merry celebrations, & guten Rutsch!

operation absurdist feature requests: terminated (http://en.wikipedia.org/wiki/Absurdism)
Posts:
150
July 13, 2010

Ack, help! We've been using the syntax Tobi posted back in 2007 since then, but all of the sudden it's not working!

We routinely use this for nested navigation using linklists.

Was the liquid parser changed?

Matt Beck, CouldBe Studios | Portland, OR | http://www.couldbestudios.com : http://deals.couldbestudios.com
Posts:
150
July 13, 2010

having to work around this with really redundant case statments as a band-aid, but it'd be great if this functionality could be restored.

Matt Beck, CouldBe Studios | Portland, OR | http://www.couldbestudios.com : http://deals.couldbestudios.com
Posts:
320
July 13, 2010

Hey Matt, do you mind submitting a ticket? http://support.myshopify.com

I run the online stores SilkArtificial.com and SnapFlyers.com | Shopify cheat sheet cheat.markdunkley.com Follow me twitter.com/markdunkley
Posts:
5840
Last edited July 13, 2010

Hi Matt,

link.handle was taken behind the shed and shot yesterday afternoon. (I hope it saw the Light but doubtful.)

Handles are meant to access resources in Liquid. They are also used to build URLs as you know...

link.handle was undocumented in the wiki, and added unnecessary strain on our link list implementation.

All you have to do is replace this:

{% assign childmenu = link.handle %}

With that:

{% capture childmenu %}{{ link.title | handle }}{% endcapture %}

(Your edits will vary, but you get the idea.)

Something else: we are being strict about link list handles now. We only accept true link list handle in the templates, so no capital letters are acceptable as these won't be down-cased.

This won't work anymore:

{% for link in linklists.Categories.links %}

This will:

{% for link in linklists.categories.links %}

If you go to the Navigation page, you can place your cursor above any menu (link list) title and you will see the handle of that menu in a tooltip. Like so:

 

Caroline from http://11heavens.com ∴ mllegeorgesand AT gmail DOT com
Posts:
150
July 13, 2010

Hi Caroline,

Thanks for the info...this sort of thing really needs to be disseminated somehow. I don't even know off the top of my head how many of my sites this change just broke.

 

Oddly I was still able to do {% assign listname = link.handle %}

What wasn't working was {% for link in linklists[listname].links %}

 

I'm capturing it now as you suggested on the client site that reported the problem to me.

Matt Beck, CouldBe Studios | Portland, OR | http://www.couldbestudios.com : http://deals.couldbestudios.com
tdej Member
Posts:
27
July 13, 2010

Hi,

I ran into the same unexpected issues today, only realizing eventually that suddenly the parser was case sensitive when it came to linklist names.

Is there a site where Shopify announces these kinds of changes that affect us by any chance?

Thanks,

Tomas

 

Posts:
1
July 13, 2010

This broke our site (well, the site we built for a client) as well and I just spent at least an an hour trying to fix it.  From past experience I haven't had tons of luck with forums so I checked here as a last resort.

It's nice to see Shopify respond quickly but it would have been even nicer to get a heads-up to this site-breaking change.

PharrOut: Richmond, VA web design and development, http://pharrout.com/
Posts:
5840
Last edited July 13, 2010

Guys, it's all my fault so you can lynch me.

I assumed these changes were intentional because I had heard that link lists' code was optimized. As it turns out, we did not intend to break any backward compatibility in our improvements.

One of our developers addressed these 2 issues already (with link.id and the link list handle capitalization) and next time we deploy these fixes will go live. It should take a couple of days, so.. if any of your shops is broken, please come to us in support and we will help you fix these things in your theme ASAP.

Matt, sorry! 

Caroline from http://11heavens.com ∴ mllegeorgesand AT gmail DOT com
bitmanic Shopify Partner bitmanic.com
Posts:
13
October 18, 2010

Hey there, Caroline.

I've tried to implement your latest suggestions (as well as many other suggestion in this thread) for getting link handles to display in my code.  I can't get this to work for the life of me, but I'm also using Vision to develop my theme.  Is this something that was fixed in production but left out of Vision?  If so, no biggie.  Just curious.  Thanks!

Bitmanic: Graphic design and web development. http://bitmanic.com.