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.

Testing If statements against a multi select

August 14, 2012 1:00pm

Subscribe [2]
  • #1 / Aug 14, 2012 1:00pm

    fasterhorses

    6 posts

    Hello,

    I"m trying to test if entries have a multi select option enabled.

    For example:

    Red
    Green
    Blue
    Yellow

    When I run an if statement to check against entries, I use this:

    {if multiselect_field == "Red"}
      {title}
    {/if}

    This works for all the entries that have only “Red” selected, but not for entries that have “Red” and another value selected (like “Yellow”)—these entries have a value of: “Red, Yellow” and therefore don’t pass the conditional.

    How (if at all) am I able to check against these values for every instance of “Red”, regardless of other selected values.

    Thanks,

    —Nick

  • #2 / Aug 14, 2012 7:21pm

    Tyssen

    756 posts

    You could probably use Switchee which can do regex matching on the input values.

  • #3 / Aug 16, 2012 10:19am

    Dan Decker

    7338 posts

    Hi Nick,

    You could also check out PVL Check If. Looks like it can check if a variable *contains* a value as well.

    ~

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

ExpressionEngine News!

#eecms, #events, #releases