| Re: Any Smarty way to check we are in front page of a site? |
| by marcionline on 2007/11/21 15:34:52 There is also this similar topic: https://xoops.org/modules/newbb/viewtopic.php?topic_id=59452 |
| Re: Any Smarty way to check we are in front page of a site? |
| by ianez on 2007/11/21 15:06:46 I don't understand why all this code for front page test.. wouldn't be much easier to use le="color: #000000"><?php <{if $xoops_requesturi == "/index.php"}> your custom code <{/if}> ? cheers Ian |
| Re: Any Smarty way to check we are in front page of a site? |
| by sabahan on 2007/11/20 5:07:52 I can't make guest_ & zyspec way to work in my site any other idea ? Quote:
agree |
| Re: Any Smarty way to check we are in front page of a site? |
| by zyspec on 2007/10/27 17:32:52 Okay... So I thought about it a little more and here's some code that will work - most of the time. Just place this code at the top of your theme (or include it) and then you can reference the <{$ishome}> smarty variable to figure out if you're on the home page. le="color: #000000"><?php <{php}> global $xoopsConfig; $xbase = basename(XOOPS_URL); $myloc = $_SERVER['PHP_SELF']; $xdir = strtolower(DIRECTORY_SEPARATOR . $xbase); if ($xdir != DIRECTORY_SEPARATOR) { $pattern = "'/".$xbase."/'"; $myloc = preg_replace($pattern,'',$myloc); } $startloc= (!empty($xoopsConfig ['startpage'])) ? 'modules'.DIRECTORY_SEPARATOR.$xoopsConfig['startpage'].DIRECTORY_SEPARATOR.'index.php' : 'index.php' ; if ( ($myloc == $startloc) && (empty($_SERVER['argv'])) ) { $this->assign('ishome',true); }else{ $this->assign('ishome',false); } <{/php}> The code at the beginning, while strange, checks to see if XOOPS is installed in a subdirectory off the site's root. So this will work even if XOOPS is installed in http://yoursite.com/xoops instead of in http://yoursite.com There's an instance where if you post variables to the module's index page then it will still tell you it's a home page, even though technically it's not the "home" page. The code in the bug report that nachenko referenced above suffers from the same limitation. EDIT:Fixed DIRECTORY_SEPARATOR for both WIN and *nix - again
|
| Re: Any Smarty way to check we are in front page of a site? |
| by nachenko on 2007/10/27 11:02:38 Although the problem is fixed for me, I'd check the bug report above and add a line after the IF statement, like this: define ("IS_FRONT", true); So we can check it in the theme, like this: {$smarty.const.IS_FRONT} |