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

<{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:
<{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}>

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...

{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

Login

Who's Online

177 user(s) are online (111 user(s) are browsing Support Forums)


Members: 0


Guests: 177


more...

Donat-O-Meter

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

Latest GitHub Commits