0
Welcome Guest! Login
0 items Join Now

Bad Coding For Gantry.php - Please Resolve

    • kykuang's Avatar
    • kykuang
    • Newbie
    • Posts: 17
    • Thanks: 0

    Bad Coding For Gantry.php - Please Resolve

    Posted 13 years 6 months ago
    • For the performance, here is the bad coding for Gantry.php that will cause multiple template styles query. This can be verified by enable debug mode...

      The following 2 functions: getMasters() and getGantryTemplates()
      can be combined into one function with only one query to $this->getTemplates();
      this will reduce SQL query to database


      private function getMasters()
      {
      $templates = $this->getTemplates();
      $masters = array();
      foreach ($templates as $template)
      {
      if ($template->params->get('master') == 'true')
      {
      $masters[] = $template->id;
      }
      }
      return $masters;
      }

      private function getGantryTemplates()
      {
      $templates = $this->getTemplates();
      $gantry = array();
      foreach ($templates as $template)
      {
      if ($template->params->get('master') != null)
      {
      $gantry[] = $template->id;
      }
      }

      return $gantry;
      }
  • Re: Bad Coding For Gantry.php - Please Resolve

    Posted 13 years 6 months ago
    • Hello, I am having problems with regard to styling.. a system issue. Will this code fix it.?

      Using Entopy: when edit style, I get the styling page but not one drop down or option works. When I select "view presets" I get a white page.

      I can do nothing with this template. I have reinstalled but no change.

      Thinking of trying to update Gantry.

      Any advice will be great.
    • Michelle
      http://www.artifectcreative.co
    • Brian Towles's Avatar
    • Brian Towles
    • Hero Rocketeer
    • Posts: 451
    • Thanks: 9
    • Geekus Maximus

    Re: Bad Coding For Gantry.php - Please Resolve

    Posted 13 years 6 months ago
    • Simple combining the function will not reduce the number of SQL queries made since the function will have to be called the same number of times as each of the individual functions is made anyways. As well the getTemplates function itself is cached internally so the SQL call is made only one time no matter how many time the wrapping functions call it. This is an internal cache and not dependent on Joomla caching being enabled or disabled.

Time to create page: 0.048 seconds