ExpressionEngine CMS
Open, Free, Amazing

Thread

This is an archived forum and the content is probably no longer relevant, but is provided here for posterity.

The active forums are here.

If conditional within an if conditional..

July 25, 2011 3:15pm

Subscribe [7]
  • #16 / Jul 25, 2011 7:19pm

    Etheya

    213 posts

    Trial and error here… if i use the following then i get the desired effect.. but its the same for every category..

    {categories}
                 
    
    
                        {if print-orientation == "Portrait"}
                        <div class="printimage fp">
                            <a href="http://{print-img}%22rel=%22example_group" rel="example_group" title="{title}">{exp:ed_imageresizer image="{print-img}" default="" maxHeight="360" alt="{title}"}</a>
                        </div>                
                        {/if}                
        
                        {if print-orientation == "Landscape"}
                        <div class="printimage">
                            <a href="http://{print-img}%22rel=%22example_group" rel="example_group" title="{title}">{exp:ed_imageresizer image="{print-img}" default="" maxWidth="360" alt="{title}"}</a>
                        </div>
                        {/if}
        
    
                    {/categories}

    so no good really…

    if i then put back in the {if category_id ==}

    {categories}
                 
                    {if category_id == "6" OR category_id == "7"}
    
                        {if print-orientation == "Portrait"}
                        <div class="printimage fp">
                            <a href="http://{print-img}%22rel=%22example_group" rel="example_group" title="{title}">{exp:ed_imageresizer image="{print-img}" default="" maxHeight="360" alt="{title}"}</a>
                        </div>                
                        {/if}                
        
                        {if print-orientation == "Landscape"}
                        <div class="printimage">
                            <a href="http://{print-img}%22rel=%22example_group" rel="example_group" title="{title}">{exp:ed_imageresizer image="{print-img}" default="" maxWidth="360" alt="{title}"}</a>
                        </div>
                        {/if}
        
                    {/if}
                    {/categories}

    then it shows nothing at all…

    so if i then just put in

    {categories}{category_id}{/categories}

    it finds the correct category_id which is 6

    so something has changed between 2.1.3 and 2.2.1 with the way it deals with the multi conditionals or something.. as as soon as i put the {if category} back in.. bearing in mind ive just seen it say its category_id 6 then it just doesnt cope with it at all..

    {categories}
                 
                    {if category_id == "6" OR category_id == "7"}
    
                        {if print-orientation == "Portrait"}
                        <div class="printimage fp">
                            <a href="http://{print-img}%22rel=%22example_group" rel="example_group" title="{title}">{exp:ed_imageresizer image="{print-img}" default="" maxHeight="360" alt="{title}"}</a>
                        </div>                
                        {/if}                
        
                        {if print-orientation == "Landscape"}
                        <div class="printimage">
                            <a href="http://{print-img}%22rel=%22example_group" rel="example_group" title="{title}">{exp:ed_imageresizer image="{print-img}" default="" maxWidth="360" alt="{title}"}</a>
                        </div>
                        {/if}
        
                    {/if}
                    {/categories}
  • #17 / Jul 25, 2011 7:20pm

    Etheya

    213 posts

    Yeah it will output the category_id on its own no problem… but as soon as i put in another set of conditionals it doesnt want to know..

    works fine in 2.1.3

  • #18 / Jul 25, 2011 7:24pm

    Etheya can you please check and see if you’re able to output anything at all from inside the category conditional? And if you can then I believe it’d definetly work to put the additional conditionals inside an embedded template.

    /Rasmus

  • #19 / Jul 25, 2011 7:29pm

    Etheya

    213 posts

    Breakthrough… this is working..

    {categories}
                 
                    {if category_id == "6" OR category_id == "7"}
    
                        {if '{print-orientation}' == "Portrait"}
                        <div class="printimage fp">
                            <a href="http://{print-img}%22rel=%22example_group" rel="example_group" title="{title}">{exp:ed_imageresizer image="{print-img}" default="" maxHeight="360" alt="{title}"}</a>
                        </div>                
                        {/if}    
                        
                        {if '{print-orientation}' == "Landscape"}
                        <div class="printimage">
                            <a href="http://{print-img}%22rel=%22example_group" rel="example_group" title="{title}">{exp:ed_imageresizer image="{print-img}" default="" maxWidth="360" alt="{title}"}</a>
                        </div>
                        {/if}                        
        
                    {/if}
                    {/categories}
  • #20 / Jul 25, 2011 7:32pm

    Great to hear man. You can have {print-orientation} in ” ” instead of ’ ’ if you want consistency 😊

    /Rasmus

  • #21 / Jul 25, 2011 7:33pm

    Etheya

    213 posts

    Just adding it now… didnt need that with 2.1.3 tho.. grrrr.. spent hours looking at this, its always something simple.. thanks for the help..

    Er du dansk?

  • #22 / Jul 25, 2011 7:35pm

    Yes det er jeg og jeg har selv banket mit hoved i bordet pga de conditionals der et par gange 😊

  • #23 / Jul 25, 2011 7:39pm

    Etheya

    213 posts

    Still get a slight error.. seems you cant use

    {if category_id != "6" OR category_id != "7" OR category_id != "13"}

    so will have to see what to use now..

  • #24 / Jul 25, 2011 7:41pm

    Etheya

    213 posts

    Tja.. det forstaa jeg! og vannligvis saa er det noe enkelt kode som maa endres… men men ... takk alikevel

  • #25 / Jul 25, 2011 7:42pm

    I have

    {if segment_2 == "2011" OR segment_2 == "2010" OR segment_2 == "2009" OR segment_2 == "2008" OR segment_2 == "2007" OR segment_2 == "2006" OR segment_2 == "2005" OR segment_2 == "2004" OR segment_2 == "2003" OR segment_2 == "2002" OR segment_2 == "2001" OR segment_2 == "2000"}

    in one of my codes though. It’d be very weird if category_id was different.

  • #26 / Jul 25, 2011 7:43pm

    And by the way can you please confirm that ’ ’ was not different from ” ” cause I’m not sure now 😊

    /Rasmus

  • #27 / Jul 25, 2011 7:47pm

    Etheya

    213 posts

    Yes you can use “...

    You should be able to use the does not equal tho.. != im checking…

  • #28 / Jul 25, 2011 7:59pm

    Etheya

    213 posts

    Needed to change it too

    {if "{category_id}" != "6" AND "{category_id}" != "7" AND "{category_id}" != "13"}

    and it now all works a treat 😊

  • #29 / Jul 25, 2011 8:03pm

    I guess we should just get used to putting all these conditionals in quotes 😊 Maybe it’s because EE is always able to compare two strings.

    Great you got it working!

    /Rasmus

  • #30 / Jul 26, 2011 6:54am

    John Henry Donovan

    12339 posts

    Etheya,

    A simple conditional should work fine. Can you confirm that 2 simple conditionals work

    {if category_id == '6'}
    .....
    {/if}
    
    {if category_id == '7'}
    .....
    {/if}

    Advanced are parsed much later so with that categories loop you may as you found out have to qualify those custom field conditionals as strings

.(JavaScript must be enabled to view this email address)

ExpressionEngine News!

#eecms, #events, #releases