Gavern Framework isFrontPage() method

Support help forum dedicated to free and commerical templates for Joomla 3 and 2.5 version.
GK User
Wed Jun 19, 2013 7:59 pm
Hi There!

I am using Bikestore v3.9 and customizing it a little bit. I am trying to hide mainbody in the Front Page by using isFrontPage() method using $this->layout->isFrontPage() but the latest version of Gavern added this line:

Code: Select all
if ($this->globalMenuActive == $this->globalMenuLanguage) {
      return true;
}


Since $globalMenuActive and $globalMenuLanguage are both null by default and if this line:

Code: Select all
     if($menuActive == $menuLanguage) {
          $this->globalMenuActive = $menuActive;
          $this->globalMenuLanguage = $menuLanguage;
          return true;
     }


is not being run when frontpage is not active, isFrontPage() will always return TRUE.

Am I reading this code right? What is the purpose of validating $this->globalMenuActive == $this->globalMenuLanguage and return TRUE when it is already validated in code above or line #129 in helper.layout.php.

Thanks,

Jackson
User avatar
Junior Boarder

GK User
Thu Jun 20, 2013 4:03 am
It is missing "return false; " at if condition inside foreach loop.
This was corrected in few templates and seems we missed this one.

Corrected code is as follows.
Code: Select all
        // 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;
                    }
                    return false;
                 }
            }
           
            if($this->globalMenuActive == $this->globalMenuLanguage) {
                 return true;
            }
               
            return false;   
        }

Above was tested in Fest template so please check and let me know if this works for you. Regarding changed code no idea but we don't ask them why : )

See you around...
User avatar
Platinum Boarder

GK User
Thu Jun 20, 2013 5:04 pm
Hi Norman,

Awesome! That worked.

Thanks a lot.
User avatar
Junior Boarder

GK User
Thu Jun 20, 2013 5:09 pm
No problem at all, see you around...
User avatar
Platinum Boarder


cron