简体   繁体   English

Joomla 2.5隐藏div

[英]Joomla 2.5 hide div

I'm trying to hide a div in my template if the URL that is opened is't the base URL or the home page. 如果打开的URL不是基本URL或主页,则试图在模板中隐藏div。 Now when a user opens a link a div should be invisible. 现在,当用户打开链接时,div应该是不可见的。 Can I detect and do this in Joomla 2.5 with php and how can I do this? 我可以在Joomla 2.5中使用php进行检测并执行此操作吗?

Try this by using javascript: 使用javascript尝试一下:

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

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

Try the below. 请尝试以下。

if(JRequest::getVar('view') == "frontpage" && JRequest::getVar('option') == 'com_content) {
    //You are viewing the homepage!
}

Note: This will not break even if you have a component installed called frontpage 注意:即使您安装了名为frontpage的组件,此操作也不会中断

An alternative 替代

$app = JFactory::getApplication();
$menu = $app->getMenu();
if ($menu->getActive() == $menu->getDefault()) {
    echo 'This is the front page';
}

http://docs.joomla.org/How_to_determine_if_the_user_is_viewing_the_front_page http://docs.joomla.org/How_to_determine_if_the_user_is_viewing_the_front_page

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM