Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 6 Next »

Prettify with Push Explained
When you have a Display Pattern with lots of values, you can prettify your code using the following logic.

1. Create an array (name: tags) for looping through terms
	{% array tags %}

2. Push values (into the array)
	{% push tags%}
    	{% if data.basicInformation %}
      		{{data.basicInformation | layer_name: "BasicInformation"}}
	{% elsif data.productInformation %}
	    {{data.productInformation | layer_name: "ProductInformation"}}
	{% endif %}
	{%endpush%}
	{% push tags%}
	{% for mediaType in data.imageAndUsageInformation.mediaType %} {{mediaType | tagbox_name}}{% endfor %}
	{%endpush%}

3. Check if something is in the array
	{% if tags.size > 0 %}

4. Display the values from the array with a filter: | uniq - which means unique values only
	{{tags | uniq | join: " | " }}

5. Show values in case array is empty
	{% else %}
    	{% if data.imageMetadata.fileName %}
        	{{data.imageMetadata.fileName}}
	    {% else %}
    	    {{id}}
    	{% endif %}
	{% endif %}
Complete Push Code Example
{% array tags %}

{% push tags%}
    {% if data.basicInformation %}
        {{data.basicInformation | layer_name: "BasicInformation"}}
{% elsif data.productInformation %}
    {{data.productInformation | layer_name: "ProductInformation"}}
{% endif %}
{%endpush%}

{% push tags%}
{% for mediaType in data.imageAndUsageInformation.mediaType %} {{mediaType | tagbox_name}}{% endfor %}
{%endpush%}

{% if tags.size > 0 %}
    {{tags | uniq | join: "_" | downcase}}
{% else %}
    {% if data.imageMetadata.fileName %}
        {{data.imageMetadata.fileName}}
    {% else %}
        {{id}}
    {% endif %}
{% endif %}


  • No labels