ExpressionEngine CMS
Open, Free, Amazing

Thread

This is an archived forum and the content is probably no longer relevant, but is provided here for posterity.

The active forums are here.

If sentence with grid and multi select

July 30, 2014 9:43pm

Subscribe [2]
  • #1 / Jul 30, 2014 9:43pm

    dristig

    1 posts

    I’m trying to do a if sentence within my grid data. I’ve got the grid “dishes” containing “dish” and a multi select defining paper size “A4, A5, A6 etc.”.
    Now I want to only show dishes:dish where dishes:paper contains ex. “A4”. But I cant figure out how to do it – or if its possible?!

    I’ve tried several things like this one:

    {dishes}
         {if dishes:paper *= "A4"} {dishes:dish} 
     {/if}
    {/dishes}

     

  • #2 / Jul 31, 2014 2:38am

    Rob Allen

    3114 posts

    Welcome to the forums

    In your multi select make sure there are no empty spaces after each paper size, if you find any you will need to resave entries to update with the new value.

    If the sizes are all 2 digit values you could just test for an equal match:

    {if dishes:paper == "A4"} {dishes:dish} 
     {/if}
  • #3 / Jul 31, 2014 6:26am

    dristig

    1 posts

    There are no spaces, but I’ve found that it works if I only have one selection of paper size per dish. But if a dish has more than one paper size it doesn’t work.

    If I just print/echo the the dishes:paper it shows as an array…so maybe my question should be on how to do a if sentence with array data? Anyone?

  • #4 / Jul 31, 2014 7:07am

    Rob Allen

    3114 posts

    Hmm in that case you may have to run several instances of the tag and use the search parameter, something like this:

    {dishes search:paper="A4"}
        {if dishes:count == "1"}A4 size
    {/if}
        {dishes:dish}
    
    {/dishes} 
    {dishes search:paper="A5"}
        {if dishes:count == "1"}A5 size
    {/if}
        {dishes:dish}
    
    {/dishes} 
    {dishes search:paper="A6"}
        {if dishes:count == "1"}A6 size
    {/if}
        {dishes:dish}
    
    {/dishes}
.(JavaScript must be enabled to view this email address)

ExpressionEngine News!

#eecms, #events, #releases