Alternative Conditional

Alternative If

Adds a new conditional parsing layer to your code. It allows you to leverage conditionals like you normally would, but it will happen way before the normal conditional parsing order. The tag returns the portions of code that had conditional values that evaluated positively.

The conditionals can be nested to any depth. This tag also works swimmingly with the native conditionals, which gives you the power to use both early and late parsed conditionals in your templates.


  • order= (required): You can optionally define what you would like to parse, and in what order. Note that you can use any combination of options and you can use them multiple times, just make sure the options are pipe (|) delimited. The default order for this tag is: vars|tags|conditionals. For increased performance, specify only what you need to parse. The options to choose from are in the list below:
    • vars - Parses all of the variables in the 'default' order.
    • params - Parse variables passed in as parameters.
    • globals - Parse global variables.
    • segs - Parse the segment variables.
    • now - Now variables in the form {now:variable_name}. By default, EE will not parse a variable if its value is unknown. The now: variables are advantageous, as they will immediately return '' if a global variable by that name is not found, or the value of the variable if it is found.
    • conditionals - Parses all of the conditionals in the 'default' order.
    • simple - Parse simple segment conditionals and simple conditionals.
    • advanced - Parse advanced conditionals.
    • tags - Parse any exp tags.
    • exp - Parse any exp tags.


{exp:ce_vars:alt_if parse="inward"}
Text outside of the conditional will display like normal.

{alt:if} logged_out && '{exp:ce_str:ing strrev}OT{/exp:ce_str:ing}' == 'TO'{/alt:if}
You are not logged in.
    {alt:if} segment_1 == 'test' {/alt:if}
    This is a test.
    This is real life.
    {if 'true' == 'true'}
        Your normal conditionals will still work as expected.
{alt:elseif} logged_in {/alt:elseif}
You are logged in.
This should never happen, as you should either be logged in, or not...

Note 1: Notice that the syntax is a bit different than the native ExpressionEngine® syntax. Namely, the {alt:if} and {alt:elseif} tags are tag pairs (have both opening and closing tags). This change allows the conditionals to be a lot more robust, as the parser will not get confused as easily.

Note 2: Be sure to use parse="inward" in your tag so that the conditionals are parsed before the rest of the tagdata is executed.

Note 3: An advanced feature of this tag is ability to use variable prefixing for your conditionals. This can be used to control parse order even further, by allowing different alt_if tags to run in a specified order. Simply add an extra tagpart to set the prefix. For example, {exp:ce_vars:alt_if:blah}{/exp:ce_vars:alt_if:blah} has a unique tagpart of blah. You could then use the prefix in your tags; {alt:if} would become {blah:alt:if}, etc.