0

Im on Expression engine 7 now. Im trying check template variable for condition. like so:

{if site_logo_path != ""}
    <img src="{site_logo_path}">
{if:else}
    <h1>Site Name</h1>
{/if}

Im tryed:

{if {site_logo_path} != ""}
{if "{site_logo_path}" != ""}
{if '{site_logo_path}' != ""}

No one is working correctly. If site_logo_path is empty string or url always displays second rule with h1.

Thanks for your attention. Regards.

3 Answers 3

0

Does your {site_logo_path} is a normal variable or it come from a layout:set?

Did you try {if !site_logo_path} ?

2
  • Thanks for ypur reply. Its normal template variable and i use it in layout. And yes, im tried that.
    – soulilya
    Feb 14 at 18:51
  • Does {site_logo_path} output something by itself?!
    – Benoit L
    Feb 15 at 19:42
0

Where is {site_logo_path} coming from?

Is it a layout variable?

{layout:set name="site_logo_path"}/some/path/file.png{/layout:set}

If so you would use in your if statement:

{layout:site_logo_path}

Is it a channel field?

{exp:channel:entries channel="some_channel"}
    {site_logo_path}
{/exp:channel:entries}

If so, it needs to be wrapped in a channel entries loop like above.

Is it a global template variable?

Then what you have tried should've worked.

Is it a template partial?

Then I don't think you can evaluate it in an if statement.

0

If it's like you want to show path then you can try this

{if site_logo_path && site_logo_path != ""}
Your condition to show logo
{if:else}
show else 
{/if}

This should do the trick. If this does not work, let me know what is your purpose and I will help you.

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.