- Code: Select all
if($this->layout->isFrontpage()) :
echo "homepage";
else :
echo "other content";
endif;
as result i get on every page echo "homepage", what is hier wrong?
Thanks.
if($this->layout->isFrontpage()) :
echo "homepage";
else :
echo "other content";
endif;
// function to check if the page is frontpage
function isFrontpage() {
if($this->globalMenuActive == null) {
// get all known languages
$languages = JLanguage::getKnownLanguages();
$menu = JSite::getMenu();
foreach($languages as $lang){
$menuActive = $menu->getActive();
$menuLanguage = $menu->getDefault($lang['tag']);
if($menuActive == $menuLanguage) {
$this->globalMenuActive = $menuActive;
$this->globalMenuLanguage = $menuLanguage;
return true;
}
}
}
if($this->globalMenuActive == $this->globalMenuLanguage) {
return true;
}
return false;
}
// function to check if the page is frontpage
function isFrontpage() {
if($this->globalMenuActive == null) {
// get all known languages
$languages = JLanguage::getKnownLanguages();
$menu = JFactory::getApplication()->getMenu();
foreach($languages as $lang){
$menuActive = $menu->getActive();
$menuLanguage = $menu->getDefault($lang['tag']);
if($menuActive == $menuLanguage) {
$this->globalMenuActive = $menuActive;
$this->globalMenuLanguage = $menuLanguage;
return true;
}
return false;
}
}
if($this->globalMenuActive == $this->globalMenuLanguage) {
return true;
}
return false;
}