Skip to content

Commit

Permalink
Accept text to append to the title.
Browse files Browse the repository at this point in the history
  • Loading branch information
anagh-p committed Oct 3, 2017
1 parent f3a9a26 commit e71d531
Show file tree
Hide file tree
Showing 7 changed files with 17 additions and 14 deletions.
4 changes: 2 additions & 2 deletions src/Quintype/Seo.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,15 @@ public function home($pageType){
}

public function search($query){
return new Search($query);
return new Search($this->config, $query);
}

public function section($pageType, $sectionName, $sectionId){
return new Section($this->config, $pageType, $sectionName, $sectionId);
}

public function staticPage($title){
return new StaticPage($title);
return new StaticPage($this->config, $title);
}

public function story($pageType, $story){
Expand Down
3 changes: 2 additions & 1 deletion src/Quintype/Seo/Base.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,12 @@
namespace Quintype\Seo;

class Base {
function __construct($config, $pageType, $sectionId = ''){
function __construct($config, $pageType = '', $sectionId = ''){
$this->config = $config;
$this->pageType = $pageType;
$this->sectionId = $sectionId;
$this->seoMetadata = $this->getSeoMetadata();
$this->titleTextToAppend = isset($this->config['titleTextToAppend']) ? $this->config['titleTextToAppend'] : '';
}

private function getSeoMetadata() {
Expand Down
7 changes: 4 additions & 3 deletions src/Quintype/Seo/Search.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,14 @@

namespace Quintype\Seo;

class Search
class Search extends Base
{
function __construct($query){
function __construct($config, $query){
parent::__construct($config);
$this->query = $query;
}

function prepareTags() {
return ['title' => trim($this->query) ." - Search Results"];
return ['title' => "Search results for " . trim($this->query) . $this->titleTextToAppend];
}
}
4 changes: 2 additions & 2 deletions src/Quintype/Seo/Section.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,12 @@ function prepareTags() {
protected function getPageTitle(){
if(isset($this->seoMetadata['page-title'])){
if($this->seoMetadata['page-title']==''){
return $this->sectionName . " - " . $this->config['title'];
return $this->sectionName . $this->titleTextToAppend;
}else{
return $this->seoMetadata['page-title'];
}
} else {
return $this->sectionName . " - " . $this->config['title'];
return $this->sectionName . $this->titleTextToAppend;
}
}
}
5 changes: 3 additions & 2 deletions src/Quintype/Seo/StaticPage.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,12 @@

class StaticPage extends Base
{
function __construct($title){
function __construct($config, $title){
parent::__construct($config);
$this->title = $title;
}

function prepareTags() {
return ['title' => trim($this->title)];
return ['title' => trim($this->title) . $this->titleTextToAppend];
}
}
2 changes: 1 addition & 1 deletion src/Quintype/Seo/Story.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ public function prepareTags()
{
if (sizeof($this->story) > 0) {
return [
'title' => trim($this->getTitle() . ' | '. $this->config['title']),
'title' => trim($this->getTitle()) . $this->titleTextToAppend,
'description' => trim($this->getDescription()),
'keywords' => trim($this->getKeywords(["stories" => $this->story])),
'news_keywords' => trim($this->getKeywords(["stories" => $this->story])),
Expand Down
6 changes: 3 additions & 3 deletions src/Quintype/Seo/Tag.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@

namespace Quintype\Seo;

class Tag
class Tag extends Base
{
function __construct($config, $tag){
$this->config = $config;
parent::__construct($config);
$this->tag = $tag;
}

function prepareTags() {
return ['title'=>trim($this->tag) . " - " . $this->config['title']];
return ['title'=>trim($this->tag) . $this->titleTextToAppend];
}
}

0 comments on commit e71d531

Please sign in to comment.