I'm working on EE 2.8.1, Stash 2.5.2 and ChannelImages 5.4.15.
I'm new to Stash. In a channel entry with limit 1 if've got the following:
{exp:stash:set_list name="l_portfolio" parse_tags="yes" parse_depth="2"}
{portfolio_related_home}
{stash:item_title}{portfolio_related_home:title}{/stash:item_title}
{stash:item_id}{portfolio_related_home:count}{/stash:item_id}
{portfolio_related_home:portfolio_images limit="3" prefix="ci"}
{if ci:count == '1'}
{stash:img1{portfolio_related_home:count}}{ci:url:medium}{/stash:img1{portfolio_related_home:count}}
{/if}
{if ci:count == '2'}
{stash:img2{portfolio_related_home:count}}{ci:url:small}{/stash:img2{portfolio_related_home:count}}
{/if}
{if ci:count == '3'}
{stash:img3{portfolio_related_home:count}}{ci:url:small}{/stash:img3{portfolio_related_home:count}}
{/if}
{/portfolio_related_home:portfolio_images}
{/portfolio_related_home}
{/exp:stash:set_list}
I know that it would be best to use a nested list for the portfolio images. But I only need three images and they need to be parsed in different order per related entry. Portfolio_related_home is the relationship field. portfolio_images is the ChannelImages field.
When I output stash. It almost works. The only thing is that the images per related entry are the same. So I'm getting three images witch are the same. The ci:count works but when I output ci:id or ci:url they keep the same.
{exp:stash:get_list name="l_portfolio" }
<div>
{if item_id <> '2'}
<div class="hp-img-container" ><img src="{img1{item_id}}" />
<div class="hp-content"><h4>{item_title}</h4>
<p>{item_content}</p>
</div>
</div>
<img src="{img2{item_id}}" />
<img src="{img3{item_id}}" />
{if:else}
<img src="{img2{item_id}}" />
<img src="{img3{item_id}}" />
<div class="hp-img-container" ><img src="{img1{item_id}}" />
<div class="hp-content"><h4>{item_title}</h4>
<p>{item_content}</p>
</div>
</div>
{/if}
</div>
{/exp:stash:get_list}
And the final HTML:
<div>
/uploads/images/18/img02__small.jpg">
/uploads/images/18/img02__small.jpg">
<div class="hp-img-container">/uploads/images/18/img02__large.jpg
<div class="hp-content"><h4>Title</h4>
</div>
</div>
</div>
<div>
<div class="hp-img-container">/uploads/images/19/img03__large.jpg
<div class="hp-content"><h4>Title 2</h4>
</div>
</div>
/uploads/images/19/img03__small.jpg
/uploads/images/19/img03__small.jpg
</div>
I must be doing something wrong. Or there must be a better way to do this. I hope someone can help me out?
Tnx