-
Notifications
You must be signed in to change notification settings - Fork 333
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
NEW Use autoscaffolding for SiteTree CMS fields #2983
NEW Use autoscaffolding for SiteTree CMS fields #2983
Conversation
'CustomMetaDescription' => 'Text', | ||
'CustomExtraMeta' => 'HTMLText' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These come from SubsitesVirtualPage
(see silverstripe/silverstripe-subsites#589). They make a lot of sense to add here, and not much sense to have explicitly only for the subsites version of this page.
/** | ||
* Whether to allow overriding the meta description and extra meta tags. | ||
*/ | ||
private static bool $allow_meta_overrides = true; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Minimises upgrades pain for people who don't want those new fields
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
None of these translations were being used, and instead explicit keys were being used. We're relying on scaffolding which relies on fieldLabel()
now, and that method relies on the keys here. So I've updated their values to match what we expect.
// Remove all metadata fields, does not apply for redirector pages | ||
$fields->removeByName('Metadata'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a composite field that gets manually added, so we can't use ignoreFields
for it.
537dd34
to
cd1c06a
Compare
code/Model/SiteTree.php
Outdated
$dependentTable = new LiteralField('DependentNote', '<p></p>'); | ||
$this->beforeUpdateCMSFields(function (FieldList $fields) { | ||
$dependentNote = ''; | ||
$dependentTable = new LiteralField('DependentNote', '<p></p>'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
$dependentTable = new LiteralField('DependentNote', '<p></p>'); | |
$dependentTable = LiteralField::create('DependentNote', '<p></p>'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I didn't add this code - and broadly changing from new
to create
should be done as part of silverstripe/silverstripe-framework#10269.
I'll make the changes here just to avoid ping pong.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
code/Model/SiteTree.php
Outdated
]; | ||
if (class_exists(Subsite::class)) { | ||
$dependentColumns['Subsite.Title'] = Subsite::singleton()->i18n_singular_name(); | ||
$dependentNote = new LiteralField('DependentNote', '<p>' . _t(__CLASS__.'.DEPENDENT_NOTE', 'The following pages depend on this page. This includes virtual pages, redirector pages, and pages with content links.') . '</p>'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
$dependentNote = new LiteralField('DependentNote', '<p>' . _t(__CLASS__.'.DEPENDENT_NOTE', 'The following pages depend on this page. This includes virtual pages, redirector pages, and pages with content links.') . '</p>'); | |
$dependentNote = LiteralField::create('DependentNote', '<p>' . _t(__CLASS__.'.DEPENDENT_NOTE', 'The following pages depend on this page. This includes virtual pages, redirector pages, and pages with content links.') . '</p>'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
code/Model/SiteTree.php
Outdated
$metaFieldDesc = new TextareaField("MetaDescription", $this->fieldLabel('MetaDescription')), | ||
$metaFieldExtra = new TextareaField("ExtraMeta", $this->fieldLabel('ExtraMeta')) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
$metaFieldDesc = new TextareaField("MetaDescription", $this->fieldLabel('MetaDescription')), | |
$metaFieldExtra = new TextareaField("ExtraMeta", $this->fieldLabel('ExtraMeta')) | |
$metaFieldDesc = TextareaField::create("MetaDescription", $this->fieldLabel('MetaDescription')), | |
$metaFieldExtra = TextareaField::create("ExtraMeta", $this->fieldLabel('ExtraMeta')) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
db_RedirectionType: 'Redirection type' | ||
has_one_LinkTo: 'Link to' | ||
has_one_LinkToFile: 'Link to file' | ||
db_ExternalURL: 'Other website URL' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We shouldn't change translation source values, as when we tx push it'll delete any existing translations
Create new keys if you need to change values
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See #2983 (comment)
I've linked to that comment from other PRs that you've approved, so presumably you broadly agree with it?
Note that db
keys and has_one
keys are directly used in fieldLabels()
in a dynamic way. We can't really substitute them with other keys in a particularly clean way or I'd just use the existing ones that I'm intentionally swapping away from (again see the comment linked above).
cd1c06a
to
c30e89c
Compare
Issue