Fix homepage title when auto_landing is disabled fixes #456

Cette révision appartient à :
Stéphane Goetz 2017-05-16 23:17:06 +02:00
Parent 30b6b2c2d4
révision ea61ca0210
3 fichiers modifiés avec 20 ajouts et 7 suppressions

Voir le fichier

@ -5,6 +5,11 @@ use Todaymade\Daux\Format\HTML\Config as HTMLConfig;
class Config extends BaseConfig
{
public function getTitle()
{
return $this['title'];
}
public function getCurrentPage()
{
return $this['current_page'];

Voir le fichier

@ -9,11 +9,6 @@ class ContentPage extends \Todaymade\Daux\Format\Base\ContentPage
private function isHomepage()
{
// If we don't have the auto_landing parameter, we don't want any homepage
if (array_key_exists('auto_landing', $this->params['html']) && !$this->params['html']['auto_landing']) {
return false;
}
// If the current page isn't the index, no chance it is the landing page
if ($this->file->getParent()->getIndexPage() != $this->file) {
return false;
@ -23,6 +18,15 @@ class ContentPage extends \Todaymade\Daux\Format\Base\ContentPage
return $this->file->getParent() instanceof Root;
}
private function isLanding() {
// If we don't have the auto_landing parameter, we don't want any homepage
if (array_key_exists('auto_landing', $this->params['html']) && !$this->params['html']['auto_landing']) {
return false;
}
return $this->homepage;
}
private function initialize()
{
$this->homepage = $this->isHomepage();
@ -91,12 +95,16 @@ class ContentPage extends \Todaymade\Daux\Format\Base\ContentPage
if ($page['breadcrumbs']) {
$page['breadcrumb_trail'] = $this->getBreadcrumbTrail($this->file->getParents(), $params->isMultilanguage());
$page['breadcrumb_separator'] = $params['html']['breadcrumb_separator'];
if ($this->homepage) {
$page['breadcrumb_trail'] = [$this->file->getTitle() => ''];
}
}
$context = ['page' => $page, 'params' => $params];
$template = new Template($params['templates'], $params['theme']['templates']);
return $template->render($this->homepage ? 'theme::home' : 'theme::content', $context);
return $template->render($this->isLanding() ? 'theme::home' : 'theme::content', $context);
}
}

Voir le fichier

@ -117,7 +117,7 @@ class Builder
if ($entry->getUri() == $config['index_key']) {
if ($parent instanceof Root) {
$entry->setTitle($config['title']);
$entry->setTitle($config->getTitle());
} else {
$entry->setTitle($parent->getTitle());
}