Commit 27b1bd9d authored by Tino Goratsch's avatar Tino Goratsch

improve the rendering of the meta title for the homepage

parent 1c12c343
......@@ -62,22 +62,34 @@ class Title extends \ACP3\Core\Breadcrumb\Title
public function getSiteAndPageTitle()
{
if ($this->request->isHomepage()) {
return $this->renderHomepageTitle();
}
$settings = $this->getSettings();
if ($this->allowSystemSubtitle() && $settings['site_subtitle_mode'] == 2) {
$this->setSiteSubtitle('');
}
return parent::getSiteAndPageTitle();
}
private function renderHomepageTitle(): string
{
if ($this->allowSystemSubtitle()) {
if ($this->request->isHomepage()) {
if ($settings['site_subtitle_homepage_mode'] == 1) {
$title = $this->getSiteSubtitle();
$title .= $this->getSiteTitleSeparator() . $this->getSiteTitle();
return $title;
}
} elseif ($settings['site_subtitle_mode'] == 2) {
$settings = $this->getSettings();
if ($settings['site_subtitle_homepage_mode'] == 1) {
$this->setMetaTitle($this->getSiteSubtitle());
$this->setSiteSubtitle('');
}
}
return parent::getSiteAndPageTitle();
return $this->renderSiteTitle()
. $this->renderSiteSubTitle()
. $this->renderPageTitlePrefix()
. $this->renderPageTitle()
. $this->renderPageTitleSuffix();
}
private function allowSystemSubtitle(): bool
......@@ -88,9 +100,22 @@ class Title extends \ACP3\Core\Breadcrumb\Title
protected function renderSiteSubTitle(): string
{
if ($this->allowSystemSubtitle()) {
if ($this->request->isHomepage() && !empty($this->getSiteSubtitle())) {
return $this->getSiteSubtitle() . $this->getPageTitleSeparator();
}
return parent::renderSiteSubTitle();
}
return '';
}
protected function renderSiteTitle(): string
{
if ($this->request->isHomepage() && !empty($this->getSiteTitle())) {
return $this->getSiteTitle() . $this->getPageTitleSeparator();
}
return parent::renderSiteTitle();
}
}
......@@ -104,21 +104,21 @@ class TitleTest extends \ACP3\Core\Test\Breadcrumb\TitleTest
{
$this->setUpStepsExpectations(0);
$this->requestMock->expects($this->once())
$this->requestMock->expects($this->atLeastOnce())
->method('isHomepage')
->willReturn(true);
$this->setUpConfigMockExpectations('SEO Title', 'Subtitle', 1, 1);
$this->titleConfigurator->configure($this->title);
$this->assertEquals('Subtitle | SEO Title', $this->title->getSiteAndPageTitle());
$this->assertEquals('SEO Title - Subtitle', $this->title->getSiteAndPageTitle());
}
public function testGetSiteAndPageTitleForNotHomepage()
{
$this->setUpStepsExpectations(1);
$this->requestMock->expects($this->once())
$this->requestMock->expects($this->atLeastOnce())
->method('isHomepage')
->willReturn(false);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment