0

如果打开的 URL 不是基本 URL 或主页,我会尝试在模板中隐藏 div。现在,当用户打开链接时,div 应该是不可见的。我可以在 Joomla 2.5 中使用 php 检测并执行此操作吗?我该如何执行此操作?

4

2 回答 2

0

使用 javascript 试试这个:

if(window.location.href.indexOf("base url")>0){
    $('something').show();
}
else{
        $('something').hide();
}

演示小提琴:http: //jsfiddle.net/surendraVsingh/ZHsH7/

于 2012-06-25T05:23:07.483 回答
0

试试下面的。

if(JRequest::getVar('view') == "frontpage" && JRequest::getVar('option') == 'com_content) {
    //您正在查看主页!
}

注意:即使您安装了一个名为的组件,这也不会中断frontpage

替代

$app = JFactory::getApplication();
$menu = $app->getMenu();
if ($menu->getActive() == $menu->getDefault()) {
    echo '这是首页';
}

http://docs.joomla.org/How_to_determine_if_the_user_is_viewing_the_front_page

于 2012-06-25T05:23:11.947 回答