日期:2017-05-20 阅读:2162
dmandwp系统 - wordpress系统和DM系统区块建站>>
https://docs.joomla.org/How_to_determine_if_the_user_is_viewing_the_front_page
在模板的index.php写下面代码测试:
$app = JFactory::getApplication(); //这个在index.php里有的。
$menu = $app->getMenu();
//var_dump($menu);
if ($menu->getActive() == $menu->getDefault()) {
echo 'This is the front page';
}
如果是多语言,则要用下面判断
$lang = JFactory::getLanguage();
if ($menu->getActive() == $menu->getDefault($lang->getTag())) {
echo 'This is the front page';
}
而$lang->getTag()则是zh-CN
其实在模板里也有这个代码:
<html lang="<?php echo $this->language; ?>" dir="<?php echo $this->direction; ?>">
echo $this->language;结果是zh-cn(小写了)
------------------
得到别名:
echo $menu->getActive()->alias;
<body class="<?php echo $active->alias; ?> ">这样,就可以自定义class了