Take the 2-minute tour ×
ExpressionEngine® Answers is a question and answer site for administrators, end users, developers and designers for ExpressionEngine® CMS. It's 100% free, no registration required.

Sorry but I'm unable to use switchee.. how can i set AND conditionals?

this is my original code:

<!--The Categories Page ////////////-->
{if segment_2=="" AND segment_3==""}
{embed="travels/travels"}

<!--The Category Entries Page //////-->
{if:elseif segment_2!="" AND segment_3==""}
{embed="travels/trip"}

<!--The Single Entry ///////////////-->
{if:elseif segment_3!=""}
{embed="travels/trip"}

{/if}

thanks!

share|improve this question
2  
In this case it would be more useful using ifelse than switchee. Developed from the same author: Marc Croxton. –  Stéphane Mar 2 at 17:43
    
Yeah! ifelse works well in this case, thank you Stéphane –  Valerio Mar 2 at 18:44

1 Answer 1

up vote 2 down vote accepted

It's easy, actually. You can concatenate both segments. I used to use some RegEx for this, but I just got the idea to take advantage of the parsing order.

Please, try this:

{exp:switchee variable="{segment_2}/{segment_3}" parse="inward"}
    {case value="/"}
        {embed="travels/travels"}
    {/case}
    {case value="{segment_2}/"}
        {embed="travels/trip"}
    {/case}
    {case value="{segment_2}/{segment_3}"}
        {embed="travels/trip"}
    {/case}
{/exp:switchee}

There's no performance gain by using switchee on this case because the embeds are parsed after the advanced conditionals.

share|improve this answer
    
Thank you Robson, I'll try your solution and the if else add-on by Marc Croxton too.. I really need to boost the performance –  Valerio Mar 2 at 18:43

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.