I want to put Liquid code in a metafield with value type string. This is the Liquid code:
{% unless shop.metafields.cmld == blank %}
{%- assign cmld = shop.metafields.cmld -%}
<div class="slider">
{%- for field in cmld -%}
<div>
<img src="{{ field | last }}" />
</div>
{% endfor %}
</div>
{% endunless %}
The Liquid code works fine when I try it on shopify. The problem here is this error on the 1st row:
{%'(T_CONSTANT_ENCAPSED_STRING), expecting ')' in .....
Any suggestions? It looks like this:
$add_metafield= array(
"metafield" => array(
"namespace"=> $metafield_namespace,
"key"=> "something",
"value" => "{% unless shop.metafields.".$metafield_namespace." == blank %}{%- assign ".$metafield_namespace." = shop.metafields.".$metafield_namespace." -%}<div class="slider">{%- for field in ".$metafield_namespace." -%}<div><img src="{{ field | last }}" /></div>{% endfor %}</div>{% endunless %}",
"value_type" => "string"
)
);