Creating dynamic linklists with variables

DoomyDoomer
New Member
2 0 1
 

I'm trying to create navigation based on the parent list's title with an appended string. In other words, For example, if the parent's handle is "Kids", I'm assigning this to a variable and appending "-categories" to create "kids-categories", which is the name of the other linklist I'm trying to create dynamically. If I type in "kids-categories" into the for loop manually, it works as expected. I've also tested to make sure {{ list_handle }} outputs "kids-categories". My only guess is this has something to do with using a string to build a linklist object call. What am I missing?

 

Here's a code snippet:

{% assign list_handle = link.title | handleize | append: '-categories' %}
{% for link in linklists.list_handle.links %}
...outputs links...
{% endfor %}
 
0 Likes
DoomyDoomer
New Member
2 0 1

I took a 10 minute break and immediately noticed it was syntax. *sigh*. Here's the working code in case anyone else has this issue:

 

{% assign list_handle = link.title | handleize | append: '-categories' %}
{% for link in linklists[list_handle].links %}
...actually outputs links...  
{% endfor %}
tablocreative
Tourist
4 0 0

Worked for me! Thank you for this solution!

0 Likes