Created
May 23, 2018 12:56
-
-
Save CB9TOIIIA/4e4faad3dca68a386dccff4914317575 to your computer and use it in GitHub Desktop.
onBeforeCompileHead inolight
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public function onBeforeCompileHead() | |
{ | |
$sefConfig = $this->_config->getGroup('config.sef'); | |
$isSite = $this->app->jbenv->isSite(); | |
if ($sefConfig->get('enabled') && $sefConfig->get('fix_canonical') && $isSite) { | |
$this->app->jbsef->canonicalFix(); | |
} | |
$categoryId = $this->app->jbrequest->getSystem('category'); | |
if ($categoryId > 0) { | |
$category = $this->app->table->category->get($categoryId); | |
if ($category) { | |
$params = $category->getParams('site'); | |
$title = $params->get('metadata.title') ? $params->get('metadata.title') : $category->newTitle; | |
if ($title) { | |
$this->app->document->setTitle($this->app->zoo->buildPageTitle($title)); | |
} | |
$description = $params->get('metadata.description'); | |
if ($description) { | |
$this->app->document->setDescription($description); | |
} | |
$keywords = $params->get('metadata.keywords'); | |
if ($keywords) { | |
$this->app->document->setMetadata('keywords', $keywords); | |
} | |
} | |
} | |
$itemId = $this->app->jbrequest->getSystem('item'); | |
if ($itemId) { | |
$item = $this->app->table->item->get($itemId); | |
if ($item) { | |
$title = $item->getParams()->get('metadata.title'); | |
$title = $item->name; | |
// $this->app->document->setTitle($this->app->zoo->buildPageTitle($title)); | |
// AAAaaaa https://www.youtube.com/watch?v=I2sLr1kPjNg | |
foreach (array('keywords', 'author', 'robots') as $meta) { | |
if ($value = $item->getParams()->get('metadata.' . $meta)) { | |
$this->app->document->setMetadata($meta, $value); | |
} | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment