EE 1
EE 2
Switchee

Developer

Mark Croxton

3rd Party (Free)

615 downloads (last 90 days)


Compatibility

If an item is crossed out, it might be untested, not applicable or incompatible. Contact the developer to be sure.

  • Updater
  • Multi Site Manager
  • Stand Alone Entry Form
  • Low Variables
  • Content Elements
  • Better Workflow
  • Matrix
  • Grid
  • Entry API
  • Publisher

Requirements

  • jQuery for the Control Panel

Add-On Type(s)

Plugin

Tags

Editor's Pick
Each month the devot:ee staff picks an add-on that's especially well thought out, well built, and useful. They're add-ons that we love and think you will too!

Switchee was chosen in May 2012.

Use switch/case control logic in your templates.

With EEs if/else advanced conditionals, each condition is parsed before being removed at the end of the template parsing process. This means if you wrap if/else tags around lots of other tags then your template will be running many unnecessary queries and functions.

Using Switchee instead you can ensure that unmatched conditions are removed from the template before they can be parsed. This can make your template significantly more efficient and your pages will render more quickly.

Switchee allows you to use regular expressions to perform advanced matching on case conditions. Like PHPs switch/case, Switchee supports a default value.

Example:

{exp:switchee variable = "{variable_to_test}" parse="inward"}
    
    {case value="value1"}
        Content to show
    {/case}
    
    {case value="value2" default="Yes"}
        Content to show
    {/case}
    
    {case value="value3"}
        Content to show
    {/case}
 
{!-- detect pagination, for example --}
 {case value="#^P(\\d+)$#|''"}
        Use regular expressions enclosed by hashes #regex#
        Be careful to encode the following reserved characters as follows:
        { = & #123;
        | = & #124;
        } = & #125;
        Use '' to represent an empty string
    {/case}
  
{/exp:switchee}

Note that ‘default’ can also be used on it’s own:

{case default="Yes"}

Download Switchee

EE Support Downloads Add-On Version Release Date
Not Specified Download 2.1.1 2014-03-31 02:27 PM
Not Specified Download 1.6 2010-10-12 01:00 AM

Switchee Links

This entry was created February 16, 2010, 6:24 am.
This entry was last updated March 31, 2014, 9:27 am.

Disclaimer: Information about ExpressionEngine add-ons is provided as a service to you, the user, and every member of the ExpressionEngine community. devot:ee is not responsible if you hose, mangle, wreck, or otherwise destroy your EE website by installing an add-on that you found out about at this site, regardless of its rating, Favorites status, commercial or free status, or general popularity. Caveat EEmptor!

13 Reviews:

Loughlin 05.27.14

Loughlin
Rating - {addon_rating_average}

This is one of those plugins that makes you wonder when it will be absorbed into the core of Expression Engine.  This never lets me down, this gets implemented along with stash every single install…

lehrerfreund 04.30.14

lehrerfreund
Rating - {addon_rating_average}

The native if-else-logic of EE is very performance-intensive. Switchee is SO ultra-useful, because it allows you to use complex templates without bringing the server onto his knees.

Interact Marketing 02.11.14

Rating - {addon_rating_average}

Should be integrated into EE by default

96black 11.19.13

96black
Rating - {addon_rating_average}

A tried and true plugin that we use everywhere often to get pagination and article listing vs. detail pages showing. All with one simple Switchee tag pair!

Ben Kohl 08.09.13

Ben Kohl
Rating - {addon_rating_average}

I can’t imagine building an EE site without this add-on. The nesting capability is outstanding.

Media Surgery 03.16.12

Media Surgery
Rating - {addon_rating_average}

Excellent addition to the EE ‘performance’ range of add ons.

JCDerrick 12.14.11

JCDerrick
Rating - {addon_rating_average}

This is a brilliant add-on for replacing EE’s native conditional statements. At first I wasn’t sure how much of a performance boost I’d really see using this add-on, but as time has gone on, I’ve realized this is an invaluable tool for any EE developer. Excellent add-on.

Curtis Blackwell 08.25.11

Rating - {addon_rating_average}

Being able to nest Switchee with the v2.0.1 beta has greatly simplified quite a few of my templates and significantly reduced my number of templates.

sm9 07.15.11

sm9
Rating - {addon_rating_average}

Switchee gave me a nice boost in performance over using standard EE conditionals. It even helped on a page full of basic conditionals, reducing page load times by 80% in some cases. Fantastic addon, thanks!

iain 07.14.11

iain
Rating - {addon_rating_average}

I couldn’t believe the performance gains when I first saw them using this add-on. Game changer.

marcusneto 04.30.11

Rating - {addon_rating_average}

Amazing. I love the functionality that this adds to our arsenal. Great work!

Ryan Masuga 09.01.10

Ryan Masuga
Rating - {addon_rating_average}

I frequently use a single template to do various things (list of entries, single-entry page and more) and Switchee allows me to do this knowing that we won’t have a lot of unnecessary queries running for non-matching cases.

Much better and cleaner than using simple conditionals. Nice work.

Jacob Russell 09.01.10

Jacob Russell
Rating - {addon_rating_average}

Great way to get around the problems with EE complex if statements parsing their contents early, which can put a major load on pages.  Also useful for situations where Case makes more sense then If/Else, obviously.