1

the URL is like: myweb.com/home/8-sticker-papdie.html

I use:

{if $smarty.server.SCRIPT_URI|strstr:"home"}
Display message "YES"
{else}
None
{/if}

When I run it I can only see "None".

What I am doing wrong?

Andrei
  • 497
  • 2
  • 8
  • 18
  • This works for me, in case someone else has same problem: {if strstr($smarty.server.REQUEST_URI, 'home') !== false} Display message "YES" {else} None {/if} – Andrei Dec 03 '14 at 09:30
  • As you have problably already found out, `SCRIPT_URI` variable is no longer supported by PHP (no trace of it in [docs](http://docs.php.net/manual/en/reserved.variables.server.php)) and is not working on certain range of servers or hosts -- look [here](http://stackoverflow.com/q/717874/1469208) or [here](http://stackoverflow.com/q/8398391/1469208). – trejder Dec 03 '14 at 10:00

3 Answers3

1

You can just use the value of $_SERVER['HTTP_HOST']:

{if strstr($_SERVER['HTTP_HOST'], 'home') !== false}
    Display message "YES"
{else}
    None
{/if}
Jerodev
  • 32,252
  • 11
  • 87
  • 108
0

If you need URL/domain name

$_SERVER['HTTP_HOST']
CaPs LoCk
  • 150
  • 4
0

Try this it will help you :

{if $smarty.server.REQUEST_URI|strstr:"home"}
Display message "YES"
{else}
None
{/if}
Debug Diva
  • 26,058
  • 13
  • 70
  • 123