issue with Liquid module_data loop with if statement
i having issue getting below if statement function inside loop. works fine when outside loop on single post, not seem take assign when inside.
{module_data resource="blogposts" version="v3" fields="id,posttitle,postfeaturedimage,postbody,releasedate" template="" order="-id" limit="5" skip="3" collection="blogposts"}
{% item in blogposts.items%}
{% if item.postfeaturedimage == "" %}
{% assign item.postfeaturedimage = "/_assets/img/default_blog_picture.jpg" -%}
{% endif %}
<div class="row">
<div class="large-4 columns">
<p><a href="{{ item.posturl }}" title="read more"><img src="{{ item.postfeaturedimage }}?action=thumbnail&width=1200&height=600&algorithm=fill_proportional" alt="{{ item.posttitle }}"/></a></p>
</div>
<div class="large-8 columns">
<h5><a href="{{ item.posturl }}" title="{{ item.posttitle }}">{{ item.posttitle | capitalize }}</a></h5>
<p>{{ item.releasedate | date: "dddd, mmmm yyyy" }} {{ item.cat }}</p>
<p>{{ item.postbody | truncate: 220 }}</p>
<a href="{{ item.posturl }}" class="more">read more <i class="icon-angle-right"></i></a>
</div>
</div>
<hr>
{% endfor %}
thanks in advance input.
do not assign same name value.
assign value new name featured image before if, assign name inside if, or if else.
{% if item.postfeaturedimage == "" -%}
{% assign itemimage = "/_assets/img/default_blog_picture.jpg" -%}
{% else -%}
{% assign itemimage = item.postfeaturedimage -%}
{% endif -%}
{{itemimage}} image
More discussions in Developer forum
adobe
Comments
Post a Comment