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:else grid checkbox

June 20, 2014 3:42pm

Subscribe [2]
  • #1 / Jun 20, 2014 3:42pm

    andrew001

    136 posts

    Im trying to place images based on checkbox from a grid.

    The grid has a field called “checkboxes”

    in there are 3 possible answers, Food, Beer, and Salamanders

    There are only TWO images that will be displayed, an “X” or an “O”

    Any combination can be checked.

    Im trying to associate an image with whatever is checked. Is this possible, or should I not be using a grid for this?

    I tried an IF statement, but quickly ran into issues

    Basically I am trying to do this

    If checkbox 1 is checked = show this image, otherwise show that image
    if checkbox 2 is checked = show this image, otherwise show that image
    if checkbox 3 is checked = show this image, otherwise show that image

    Thanks

  • #2 / Jun 21, 2014 11:30am

    Rob Allen

    3118 posts

    Something like this?

    {grid_field}
    
    {if grid_field:checkboxes == "Food"}
       Food image
    {if:else}
       Alternative image
    {/if}
    
    {if grid_field:checkboxes == "Beer"}
       Food image
    {if:else}
       Alternative image
    {/if}
    
    {if grid_field:checkboxes == "Salamanders"}
       Food image
    {if:else}
       Alternative image
    {/if}
    
    {/grid_field}
  • #3 / Jun 23, 2014 3:32pm

    andrew001

    136 posts

    Yup, thanks. I had actually got this working friday, thats pretty much what I did.

.(JavaScript must be enabled to view this email address)

ExpressionEngine News!

#eecms, #events, #releases