Here is what I am trying to accomplish:
<ul class="site-nav__dropdown"> {% for childlink in linklists[child_list_handle].links %} this - {% assign color_from_settings = 'settings.collection_color_' | append: forloop.index %} used here - <li{% if childlink.active %} class="site-nav--active" {% else %} style="background-color: {{ color_from_settings }}" {% endif %}> <a href="{{ childlink.url }}" class="site-nav__link">{{ childlink.title | escape }}</a> </li> {% endfor %} </ul>
When this happens, I get:
background-color: settings.collection_color_1;
instead of the actual color obtained from settings_data.json, which looks like this:
{ "current": "Default", "presets": { "Default": { ... "collection_color_1": "#9997c0", "collection_color_2": "#8997b1", "collection_color_3": "#7997a2", "collection_color_4": "#699793", "collection_color_5": "#599784", "collection_color_6": "#499775", "collection_color_7": "#399766", "collection_color_8": "#299757", "collection_color_9": "#199748", "collection_color_10": "#099739" } } }
Is there a way to do this programmatically or do I really need to use <% case forloop.index%>?
source share