我有一个joomla模板,它使用这段代码来确定哪个是frontpage
function xtcIsFrontpage() {
$app = JFactory::getApplication();
$menu = $app->getMenu();
$active = $menu->getActive(); $activeid = $active ? $active->id : '';
$default = $menu->getDefault(); $defaultid = $default ? $default->id : 0;
return ( $activeid == $defaultid );
}问题是,我在这个项目中使用了多语言,当我浏览到主页时,这些语言并不被称为frontpage,但innerpage.How可以强制模板使用这些菜单默认值作为frontpage。谢谢
发布于 2014-03-05 09:37:21
好的,我自己更正了代码:D
function xtcIsFrontpage() {
$app = JFactory::getApplication();
$menu = $app->getMenu();
$lang = JFactory::getLanguage();
$active = $menu->getActive(); $activeid = $active ? $active->id : '';
$default = $menu->getDefault($lang->getTag()); $defaultid = $default ? $default->id : 0;
return ( $activeid == $defaultid );}
发布于 2014-03-05 03:46:30
这是语言帐户的代码和链接。
page
<?php
$app = JFactory::getApplication();
$menu = $app->getMenu();
$lang = JFactory::getLanguage();
if ($menu->getActive() == $menu->getDefault($lang->getTag())) {
echo 'This is the front page';
} else {
echo 'Accueil';
} ?>https://stackoverflow.com/questions/22185062
复制相似问题