How would you perform a conditional on a custom checkbox field in which the user can select 0 -4 different options?

In other words, I have a "Checkboxes" fieldtype named "{side_content_selectables}".

This fieldtype has the following options:

  • Show Search
  • Show Feed Subscription
  • Show Categories
  • Show Recent Posts

Which would just allow them to turn widgets on or off. In my template, I have the following:

<aside id="sidebar">
    {exp:channel:entries channel="side_content" limit="1" dynamic="no"}
        {if {side_content_selectables}"{item}" == "Show Search"{/side_content_selectables}}
            <section class="widget">
                {!-- Search Form --}
            <!-- /.widget -->


        {if "Show Feed Subscription"}
            <section class="widget">
                {!-- Feedburner Widget --}
            <!-- /.widget -->

Neither of these seem to work though. This makes me feel like a big noob, but I am stumped on this one. ;)

It's almost like I would need to write out a PHP script to perform a contains, but that just seems like overkill and I would like to keep PHP from being used in templates.

5 Answers 5


You're best off using the PT Checkboxes, the native ones are just too fragile for real world use.



{if {side_content_selectables:selected option="show_feed"}}
  <p>show the feed</p>
  • exactly what I was going to suggest.
    – CreateSean
    Commented Dec 10, 2012 at 18:22
  • Thanks James. I usually include those and use them as my default fieldtypes instead of the natives, I just thought I would give it a go on this one. Now I know why I default to P&T. ;)
    – W3bGuy
    Commented Dec 10, 2012 at 18:35

I second the answer posted by @James, PT Checkboxes are more flexible, but if you want to use the native checkboxes the following will work:

    {if item == "Option One"}<p>Option one is checked</p>{/if}
    {if item == "Option Two"}<p>Option two is checked</p>{/if}
    {if item == "Option Three"}<p>Option three is checked</p>{/if}

Just replace the custom field name and option values to match your situation.


I guess this would be the proper syntax

{if '{side_content_selectables}{item}{/side_content_selectables}' == 'Show Search'}

  • 1
    that would only work reliably if one and only one option were selected... Commented Dec 10, 2012 at 18:18

If you're stuck with the native field type and can't switch for whatever reason (legacy data etc) then you can always use the phpstringfun plug-in (http://devot-ee.com/add-ons/phpstringfun) and do something along the lines of:

{if "{exp:phpstringfun function='substr_count' par1='Foo'}{checkboxes_field}{/exp:phpstringfun}"=="1"}
Foo Found

Hope that helps. :)


Just joined, so I can't comment on the accepted answer, but...

the correct syntax should be (note the single quotes):

{if '{side_content_selectables:selected option="show_feed"}'}
    <p>show the feed</p>

Maybe there's been a change in the plugin since this was originally posted, but I discovered that without those single quotes, EE will throw a PHP error if none of the checkboxes are checked.

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.