public function setPageTitle() { if (!$this->container->platform->isFrontend()) { return ''; } /** @var \JApplicationSite $app */ $app = \JFactory::getApplication(); $document = \JFactory::getDocument(); $menus = $app->getMenu(); $menu = $menus->getActive(); $title = null; // Get the option and view name $option = $this->container->componentName; $view = $this->getName(); // Get the default page title translation key $default = empty($this->defaultPageTitle) ? $option . '_TITLE_' . $view : $this->defaultPageTitle; $params = $app->getParams($option); // Set the default value for page_heading if ($menu) { $params->def('page_heading', $params->get('page_title', $menu->title)); } else { $params->def('page_heading', \JText::_($default)); } // Set the document title $title = $params->get('page_title', ''); $sitename = $app->get('sitename'); if ($title == $sitename) { $title = \JText::_($default); } if (empty($title)) { $title = $sitename; } elseif ($app->get('sitename_pagetitles', 0) == 1) { $title = \JText::sprintf('JPAGETITLE', $app->get('sitename'), $title); } elseif ($app->get('sitename_pagetitles', 0) == 2) { $title = \JText::sprintf('JPAGETITLE', $title, $app->get('sitename')); } $document->setTitle($title); // Set meta if ($params->get('menu-meta_description')) { $document->setDescription($params->get('menu-meta_description')); } if ($params->get('menu-meta_keywords')) { $document->setMetadata('keywords', $params->get('menu-meta_keywords')); } if ($params->get('robots')) { $document->setMetadata('robots', $params->get('robots')); } return $title; }