0
votes

In Liquid is it possible to assign a var to combine two linklists, for example:

{% if section.settings.main_linklist == blank and section.settings.top_bar_linklist != blank %}
  {% assign navMobile = linklists[section.settings.top_bar_linklist] %}
{% else %}
  {% assign navMobile = linklists[section.settings.main_linklist] %}
{% endif %}

I want the second assign to be something like:

 {% assign navMobile = linklists[section.settings.main_linklist] and linklists[section.settings.top_bar_linklist] %}
2

2 Answers

0
votes

You can append the links with a hook of some kind between them.

For example:

{% assign navMobile = section.settings.main_linklist | append: "|" | append: section.settings.top_bar_linklist %}

Afterwards you can split them by "|" and get yourself an array.

There is no other way to save two links in a single variable in liquid.

0
votes

You may use a concat function. Not tested but something like that should work:

{% assign mobileLinks = linklists[section.settings.main_linklist] | concat: linklists[section.settings.top_bar_linklist] %}

Then you'll be able to loop through your new array:

{% for link in mobileLinks %}
    {{ link.title }}
{% endfor %}