0

I've set up the following code on a site. On my Mac (dev version - identical to the running live code) the template looks like this:

{if '{current_path}'=='/'}
...
{/if}

And this works fine. But the same code on the live version simply does not get past this if statement.

Rendering {current_path} out to the page before or after the if statement shows its value as /, but I can't get anything to evaluate inside the if.

Any clue as to what's going on?

Considerations: the live server is a Windows box.

4
  • What would be the value of current_path on the windows box?
    – foamcow
    Commented Mar 10, 2014 at 22:21
  • @foamcow It comes out as / on the Windows box right before the if
    – simonhamp
    Commented Mar 11, 2014 at 14:55
  • OK, and what is inside the if statement? Does the code execute correctly if you remove the conditional from around it?
    – foamcow
    Commented Mar 11, 2014 at 15:32
  • @foamcow yes perfectly. in fact I've had to do that now just to get it to work... but it's not with the desired result because I can't get this if to work
    – simonhamp
    Commented Mar 12, 2014 at 15:45

1 Answer 1

1

This looks like a bug, to me. Probably something related to different PHP between the environments. Starting with version 2.9, EECMS changes the way conditionals are evaluated. So this bug is probably gone.

Conditionals should always use the syntax:

{if current_path == "/"}
...
{/if}

But {current_path} is parsed at the end of parsing stages. This conditional will be evaluated after all modules and plugins run.

Why not just check for {segment_1}?

{if segment_1 == ""}
...
{/if}

Your Answer

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

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