0

I have a header snippet that includes a "Made in USA" image on it. Well the client now wants the image removed on a couple product pages. I setup an advanced conditional to check for those pages using the third url segment. It worked if I kept the conditional simple, but as soon as I added an "OR" it stopped working. I thought it was probably a parse order issue, so I installed the Croxton If/Else plugin. Implemented that and I still have the same problem. Any ideas?

Doesn't Work...

{if segment_3!="product1" OR segment_3!="product2"}
<img src="/images/styles/madeinusa.png" class="madeinusa"/>
{/if}

Doesn't Work...

{exp:ifelse parse="inward"} 
{if segment_3!='product1' OR segment_3!='product2"}
<img src="/images/styles/madeinusa.png" class="madeinusa"/>
{/if}
{/exp:ifelse}

Doesn't Work...

{exp:ifelse parse="inward"} 
{if segment_3!="product1"}
<img src="/images/styles/madeinusa.png" class="madeinusa"/>
{if:elseif segment_3!="product2"}
<img src="/images/styles/madeinusa.png" class="madeinusa"/>
{/if}
{/exp:ifelse}

Works...

    {if segment_3!="product1"}
<img src="/images/styles/madeinusa.png" class="madeinusa"/>
{/if}
1
  • 1
    With negative conditionals, you should use AND not OR. I'd also add space before and after your conditional operators to prevent any potential parsing bugs. Sep 11, 2013 at 19:14

2 Answers 2

2

I saw you already find a solution, but I think you should know the reason your code wasn't working.

Your conditional will never work... Ooops! Please, forgive me. Your conditional will always work because "product1" != "product2".

This code will always evaluate:

{if segment_3!="product1" OR segment_3!="product2"}
    <img src="/images/styles/madeinusa.png" class="madeinusa"/>
{/if}

For this code to work, you'll need an "AND", not an "OR". So:

{if segment_3!="product1" AND segment_3!="product2"}
    <img src="/images/styles/madeinusa.png" class="madeinusa"/>
{/if}

But it's really better to split this into two conditionals if your code prevents some module parsing.

1

this ended up working...Not sure why the If:Else plugin wasn't working though.

{if segment_3!="product1"}
    {if segment_3!="product2"}
    <img src="/images/styles/madeinusa.png" class="madeinusa"/>
    {/if}
{/if}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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