1
blackrx
<{if $smarty.server.PHP_SELF == '/index.php'}> not working
  • 2012/3/20 7:45

  • blackrx

  • Quite a regular

  • Posts: 227

  • Since: 2008/2/5 1


i have this is my theme

le="color: #000000"><?php <{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 ?

2
tzvook
Re: <{if $smarty.server.PHP_SELF=='/index.php'}> not working
  • 2012/3/20 15:41

  • tzvook

  • Just can't stay away

  • Posts: 875

  • Since: 2003/2/1 2


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:
le="color: #000000"><?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:

le="color: #000000"><?php <{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}>

3
blackrx
Re: <{if $smarty.server.PHP_SELF=='/index.php'}> not working
  • 2012/3/20 16:03

  • blackrx

  • Quite a regular

  • Posts: 227

  • Since: 2008/2/5 1


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>

4
tzvook
Re: <{if $smarty.server.PHP_SELF=='/index.php'}> not working
  • 2012/3/20 16:56

  • tzvook

  • Just can't stay away

  • Posts: 875

  • Since: 2003/2/1 2


Quote:
you meant theme.html right..


Yes, sorry




5
hrbhot
Re: <{if $smarty.server.PHP_SELF=='/index.php'}> not working
  • 2012/11/9 0:55

  • hrbhot

  • Just popping in

  • Posts: 1

  • Since: 2012/11/9


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

le="color: #000000"><?php {if $smarty.server.REQUEST_URI == '/index.php'}


-or-

le="color: #000000"><?php {if $smarty.server.REQUEST_URI|strstr:'index.php'}


-or-

le="color: #000000"><?php {if $smarty.server.REQUEST_URI|strpos:'/index.php' === 0}


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

le="color: #000000"><?php $smarty->assign('page','index');


in which you can then test

le="color: #000000"><?php {if $page == 'index'}


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

Login

Donat-O-Meter

Stats
Goal: $15.00
Due Date: Jul 31
Gross Amount: $0.00
Net Balance: $0.00
Left to go: $15.00
Make donations with PayPal!

Latest GitHub Commits