0

Here in this code I am finding a feed expert and then producing his avatar. Conditions are needed to control the conditions of this avatar output. So this is what must happen:

  • firstly if there is a expert in the channel entry then use his avatar BUT (here is where the if statement comes in)
  • if you choose an expert who does not have an image in the images channel then show this default image OR if you DO NOT choose an expert then also show the default image.

How do I do this? See code:

    {if "{feed_expert:total_children}" > 0}
    {exp:playa:children field="feed_expert" entry_id="{entry_id}"}
    <div class="col-sm-4 col-xs-7">
    <div class="feed-expert">
    {exp:channel_images:images entry_id="{entry_id}" field_id="185" limit="1"}
    {if image:no_images}<img src="/httpdocs/static/img/sihlouette.jpg" class="img-responsive">{/if}
<img src="{image:url}" class="img-responsive"/>
{/exp:channel_images:images}                                                </div>
 </div>  
{/exp:playa:children}  
{/if}

1 Answer 1

0

Sounds like you just need an else statement

{if "{feed_expert:total_children}" > 0} {!-- If expert is selected --}
   {exp:playa:children field="feed_expert" entry_id="{entry_id}"}
     <div class="col-sm-4 col-xs-7">
        <div class="feed-expert">
        {exp:channel_images:images entry_id="{entry_id}" field_id="185" limit="1"}
           {if image:no_images} {!-- Output default image --}
              <img src="/httpdocs/static/img/sihlouette.jpg" class="img-responsive">
           {/if}
           <img src="{image:url}" class="img-responsive"/>
        {/exp:channel_images:images}
        </div>
     </div>  
   {/exp:playa:children}  
{if:else} {!-- If no experts are selected output default image--}
   <div class="col-sm-4 col-xs-7">
     <div class="feed-expert">
        <img src="/httpdocs/static/img/sihlouette.jpg" class="img-responsive">
     </div>
   </div>
{/if}
1
  • This worked, but the images stopped displaying on the 3rd entry, seems like a limit issue. Thanks
    – ObiWanKobi
    Commented Mar 27, 2014 at 7:46

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.