IfElse
Developer
3rd Party (Free)
761 downloads (last 90 days)
EE Version Support
- ExpressionEngine 1.x
- ExpressionEngine 2
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
- Webservice
- Publisher
Requirements
- jQuery for the Control Panel
Add-On Type(s)
Plugin
Tags
IfElse was chosen in May 2012.
Early parsing of If/Else advanced conditionals.
Advanced conditionals in the ‘global’ template scope (not within a tag) are generally parsed by the EE template parser near the end of the process. This unfortunately means that any tags within non-matching conditions are parsed first, before being removed. This can have a significant performance impact if the nested tags are doing a lot of processing, such as is the case with the {exp:channel} tag.
One way around this issue is to use embeds, which are parsed after advanced conditionals. Embeds however have their own overhead, as a new instance of the template parser is needed for each one.
Happily we can now force the early parsing of advanced conditionals. Only the matching condition will remain in the template to be parsed. Here are a few examples:
{exp:ifelse parse="inward"}
{if member_id == '1' OR group_id == '2'}
Admin content
{if:elseif logged_in}
Member content
{if:else}
Public content
{/if}
{/exp:ifelse}
To preserve {if no results} conditionals inside nested tags, wrap your ‘no results’ content with {no_results}{/no_results}. Example:
{exp:ifelse parse="inward"}
{if segment_1 == 'news' AND segment_2 == 'category'}
News category page
{exp:channel:entries channel="news"}
{no_results}
No results
{/no_results}
{/exp:channel:entries}
{if:elseif segment_1 == 'news' AND segment_2 == ''}
News landing page
{if:else}
News story page
{/if}
{/exp:ifelse}
You can use any of the standard global variables, segment variables, member variables or embedded variables.
Nested tags
This plugin will not parse advanced conditionals *inside* any nested plugin/module tags; these will be left untouched for the parent tag to process.
IfElse cannot currently be nested inside itself due to a flaw in the way the EE template parser works. However, the if/else conditional tags themselves can be nested.
Download IfElse
EE Support | Downloads | Add-On Version | Release Date |
---|---|---|---|
Not Specified | Download | 1.2.1 | Oct 14, 2010 |
Not Specified | Download | 2.0.1 | Apr 9, 2014 |
This entry was created October 15, 2010, 12:02 pm.
This entry was last updated June 5, 2014, 8:31 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!
Returns: devot:ee has a 30-day return policy on all commercial add-ons sold through devot-ee.com. If you need to return an add-on, do not go to the developer or the developer's site, but rather visit our returns page at https://devot-ee.com/returns to initiate your return. If you have questions, email support@devot-ee.com.
5 Reviews:
Nicko 09.17.13
I’ve been using Beta 2.0. It works great! Just wanted to send the developer some love for making a really useful plugin!
ometiclan 02.05.13
This is AWESOME, i can’t live without it anymore. Get it people, get it! ;)
padstow 10.26.12
Just what I needed to get ce img to only crop on height or width, and not both - thank you!!
Bjørn Børresen 11.29.11
Perfect if you’re experiencing problems with EE’s performance! In many cases EE will run all tags inside all conditional brackets before stripping out what isn’t to be shown in the template. This happens even in cases where you think something is a simple conditional. Doesn’t happen with IfElse.
Martin Luff 02.14.11
I’ve found this to be super-useful; I can reduce the number of templates and do much more with more advanced conditionals without having to compromise performance. So far seems to work fine; full marks from me… ;)