201275判断joomla首页的方法

1、第一种

$isHome = false;
$menu = & JSite::getMenu();
if ( ($menu->getActive() == $menu->getDefault()) || (JRequest::getCmd('view') == 'frontpage') ) {
$isHome = true;
}

以上内容放置在</head>之前,然后<body>后面的内容就可以像下面这样调用了。
if ( $isHome ) {

// 首页内容

}

2、第二种

ID为1则显示首页
<?php if( JRequest::getVar( 'Itemid' ) == 1) { ?>
------------
首页内容
------------
<?php }else{?>
-----------
次页内容
-----------
<?php }?>

3、第三种

<?php if ((!$option)||($option!="com_frontpage"){
                            mosMainBody(); 
 }?>

4、第四种

<?php if($this->countModules('user5')) : ?>
<div id="user5" class="clearfix">
<jdoc:include type="modules" name="user5" style="jvxhtml" />
</div>
<?php endif; ?>

那么如果想要实现首页的component不显示,修改如下

<?php if (JRequest::getVar('view') != 'frontpage'): ?>

<div id="xxx" class="clearfix">
<jdoc:include type="message" />
<jdoc:include type="component" />
</div>

<?php endif; ?>

原文地址:https://www.cnblogs.com/mingziday/p/2577150.html