AK71
February 3, 2023, 12:32pm
1
I stuck in this issue. How can i used {% liquid %} to write multiple tag for this code. please help me
{%- if featured_media != null -%}
{%- capture media_index -%}
{%- if featured_media.media_type == ‘video’ or featured_media.media_type == ‘external_video’ -%}{%- increment video_index -%}
{%- elsif featured_media.media_type == ‘image’%}{%- increment image_index -%}
{%- endif -%}
{%- endcapture -%}
{% assign media_index = media_index | plus: 1 %}
{%- endif -%}
Hi @AK71 ,
This is Kate from PageFly - Landing page builder, I’d like to suggest this idea:
You try use below code:
{%- if featured_media != null -%}
{% liquid
capture media_index
if featured_media.media_type == 'video' or featured_media.media_type == 'external_video'
increment video_index
elsif featured_media.media_type == 'image'
increment image_index
endif
endcapture
assign media_index = media_index | plus: 1
%}
-
{%- endif -%}
NOTE: {% liquid %} is used to group all other liquid tags close together, other liquid tags do not need {% and %}
For example, I group this code of yours:
{% liquid
capture media_index
if featured_media.media_type == 'video' or featured_media.media_type == 'external_video'
increment video_index
elsif featured_media.media_type == 'image'
increment image_index
endif
endcapture
assign media_index = media_index | plus: 1
%}
I hope it would help you
Best regards,
Kate | PageFly