0

I just need to check if one field artist_gallery:image in a grid field is set, if not the markup should not be rendered. This syntax {if "{artist_gallery:total_rows}” > 0} or {if artist_gallery:total_rows > 0} is not working ... if there is no image, the markup is rendered.

Any ideas? Thank you!

    {if "{artist_gallery:total_rows}" > 0}
 <div id="artistgallery">
  <div class="cycle-slideshow">
   {artist_gallery}
    <img src="{artist_gallery:image}">
   {/artist_gallery}
  </div>
  <div id="adv-custom-pager" ></div>
  <div class="clb"></div>
 </div>
{/if} 
2
  • What is {artist_gallery:total_rows} printing out in your template?
    – Anna_MediaGirl
    Feb 6, 2015 at 16:18
  • 1
    I'm using the format: {if artist_gallery:total_rows >= 2} and that's working for me
    – Paul Frost
    Feb 6, 2015 at 18:39

2 Answers 2

2

Try

{if my_grid_field}
    {my_grid_field}
        Stuff in here if the grid field has rows
    {/my_grid_field}
{/if}
3
  • Still not working. Seems such a simple thing. Feb 6, 2015 at 14:57
  • {if artist_gallery:image} <div id="artistgallery"> <div class="cycle-slideshow"> {artist_gallery} <img src="{artist_gallery:image}"> {/artist_gallery} </div> <div id="adv-custom-pager" class="center external"></div> <div class="clb"></div> </div> {/if} Feb 6, 2015 at 14:59
  • If foamcow's suggestion is not working, please put in a support ticket or bug report with EllisLab. Apr 10, 2015 at 13:47
0

I've now discovered that it is a bug in 2.9.2 and there is a fix, see this question and the answers: Grid Conditionals not working

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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