Assume the URL: www.domain.com. What is {segment_1}
? It's empty, right?
Now assume the URL: www.domain.com/foo/. What is {segment_1}
? It's foo
, right?
I have this in my template:
<h1>{if segment_1 == ''}{segment_1} - case 1{/if}</h1>
<h1>{if segment_1 == 'foo'}{segment_1} - case 2{/if}</h1>
On www.domain.com, I get an output of - case 1
wrapped in h1
tags followed by an empty pair of h1
tags. This seems correct to me.
On www.domain.com/foo/, I get an output of foo - case 1
wrapped in h1
tags followed again by an empty pair of h1
tags. This is wrong. I should be getting an empty pair of h1
tags followed by foo - case 2
. Any idea what's going wrong with my conditionals?
I'm using latest version of EE. Using Stash, too.
{segment_1}
somewhere globally in your template, does it display properly throughout your site? – Derek Hogue♦ Jan 10 '13 at 14:18{segment_1}
is correct. My sample code shows that. The first if statement is always true; subsequent if statements are always false. I think that might be an accurate description of the problem as I see it right now. – ExpressionEngineNewbie Jan 10 '13 at 14:38{if segment_1 == 'foo'}{segment_1} - case 2{/if}
, does the output match your expectations? – Derek Hogue♦ Jan 10 '13 at 14:52