mirror of
https://github.com/a2nt/cms-niceties.git
synced 2024-10-22 11:05:46 +02:00
[IMPR] SEO and UX Friendly page title and nav label
This commit is contained in:
parent
3f92081041
commit
86c75af831
@ -27,4 +27,25 @@ class SiteTreeExtension extends DataExtension
|
||||
),
|
||||
]);
|
||||
}
|
||||
|
||||
public function updateCMSFields(FieldList $fields)
|
||||
{
|
||||
$f = $fields->dataFieldByName('MenuTitle');
|
||||
// Elements has own Title field to be used at content (h1 can be hidden),
|
||||
// while Menu Title (h1 page title) and Navigation label should be equal for SEO
|
||||
if ($f) {
|
||||
// name page name as navigation label to be more clear for CMS admin
|
||||
$fields->dataFieldByName('Title')->setTitle($f->Title());
|
||||
$fields->removeByName('MenuTitle');
|
||||
}
|
||||
}
|
||||
|
||||
public function onBeforeWrite()
|
||||
{
|
||||
parent::onBeforeWrite();
|
||||
|
||||
// h1 page title and navigation label should be equal for SEO
|
||||
$obj = $this->owner;
|
||||
$obj->setField('MenuTitle', $obj->getField('Title'));
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user