xoops forums

blackrx

Quite a regular
Posted on: 2012/3/20 7:45
blackrx
blackrx (Show more)
Quite a regular
Posts: 227
Since: 2008/2/5 1
#1

<{if $smarty.server.PHP_SELF == '/index.php'}> not working

i have this is my theme

<{if $smarty.server.PHP_SELF=='/index.php'}>
<
li><a href="<{$xoops_url}>/index.php" class="tabs-selected"><span>Home</span></a></li>
<{else}>
<
li><a href="<{$xoops_url}>"><span>Home</span></a></li>
<{/if}>



i would to display a slideshow and a custom menu with selected tabs for current url in main page

but its not working

it will always display the second statement

what might be wrong ?

tzvook

Just can't stay away
Posted on: 2012/3/20 15:41
tzvook
tzvook (Show more)
Just can't stay away
Posts: 875
Since: 2003/2/1 2
#2

Re: <{if $smarty.server.PHP_SELF=='/index.php'}> not working

I use this code, you can adapt it to your needs, it's far more then just "show-if-homepege":

in the beginning of my theme.php:
<{php}>
$mod $GLOBALS['xoopsModule'];
$dirname = (isset($mod) ? $mod->getVar('dirname') :'system');
$GLOBALS['xoopsTpl']->assign'xoops_cmod'$dirname );
<{/
php}>


Then in the body wherever needed:

<{if $xoops_cmod == "article"}>
Text apears if user is in the article module
<{elseif $xoops_cmod == "classifieds"}>
Text apears if user is in the classifieds module)
<{elseif 
$xoops_cmod == "directory"}>
Text apears if user is in the directory module
<{elseif $xoops_cmod == "profile"}>
Text apears if user is in the profile module
<{else}>
Text apears if user is not at the modules mentioned above
<{/if}>

blackrx

Quite a regular
Posted on: 2012/3/20 16:03
blackrx
blackrx (Show more)
Quite a regular
Posts: 227
Since: 2008/2/5 1
#3

Re: <{if $smarty.server.PHP_SELF=='/index.php'}> not working

Thank you tzvook

you meant theme.html right..

nice code..will try it

btw i found what cause my problem..and now is ok

it was a script call in <head></head>

tzvook

Just can't stay away
Posted on: 2012/3/20 16:56
tzvook
tzvook (Show more)
Just can't stay away
Posts: 875
Since: 2003/2/1 2
#4

Re: <{if $smarty.server.PHP_SELF=='/index.php'}> not working

Quote:
you meant theme.html right..


Yes, sorry



hrbhot

Just popping in
Posted on: 2012/11/9 0:55
hrbhot
hrbhot (Show more)
Just popping in
Posts: 1
Since: 2012/11/9
#5

Re: <{if $smarty.server.PHP_SELF=='/index.php'}> not working

you might be needing the leading slash on the REQUEST_URI environmental...

{if $smarty.server.REQUEST_URI == '/index.php'}


-or-

{if $smarty.server.REQUEST_URI|strstr:'index.php'}


-or-

{if $smarty.server.REQUEST_URI|strpos:'/index.php' === 0}


A cleaner approach would be to assign "page" variable to the smarty instance

$smarty->assign('page','index');


in which you can then test

{if $page == 'index'}


As any additional query string parameters on your index page will cause your very explicit match to fail