Skip to content

Commit

Permalink
restore CmsDesignDataExtension
Browse files Browse the repository at this point in the history
  • Loading branch information
jsirish committed Aug 30, 2023
1 parent f1340d8 commit 9990f9e
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 7 deletions.
33 changes: 33 additions & 0 deletions src/Extension/CmsDesignDataExtension.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
<?php

namespace Dynamic\Base\Extension;

use SilverStripe\Forms\FieldList;
use SilverStripe\ORM\DataExtension;

/**
* Class \Dynamic\Base\Extension\CmsDesignDataExtension
*
* @property SiteTree|CmsDesignDataExtension $owner
*/
class CmsDesignDataExtension extends DataExtension
{
/**
* @param FieldList $fields
*/
public function updateCMSFields(FieldList $fields)
{
if ($fields->dataFieldByName('MenuTitle')) {
$fields->insertBefore(
'MetaDescription',
$fields->dataFieldByName('MenuTitle')
);
}
if ($fields->dataFieldByName('URLSegment')) {
$fields->insertBefore(
'MetaDescription',
$fields->dataFieldByName('URLSegment')
);
}
}
}
8 changes: 1 addition & 7 deletions src/Extension/SeoExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,13 +47,7 @@ public function updateCMSFields(FieldList $fields)
}
}

if (!$this->owner instanceof VirtualPage) {
if ($page_title = $fields->dataFieldByName('Title')) {
$page_title->setTargetLength(45, 25, 60);
}
}

if (!$this->owner instanceof VirtualPage ||
if (!$this->owner instanceof VirtualPage ||
in_array('MetaDescription', $this->owner->config()->get('non_virtual_fields'))) {
if ($meta_description = $fields->dataFieldByName('MetaDescription')) {
$meta_description->setTargetLength(130, 70, static::META_CHAR_COUNT_MAX);
Expand Down

0 comments on commit 9990f9e

Please sign in to comment.