Skip to content
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

Merged

Conversation

GuySartorelli
Copy link
Member

Comment on lines +82 to +83
'CustomMetaDescription' => 'Text',
'CustomExtraMeta' => 'HTMLText'
Copy link
Member Author

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.

Comment on lines +94 to +97
/**
* Whether to allow overriding the meta description and extra meta tags.
*/
private static bool $allow_meta_overrides = true;
Copy link
Member Author

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

Copy link
Member Author

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.

Comment on lines 201 to 202
// Remove all metadata fields, does not apply for redirector pages
$fields->removeByName('Metadata');
Copy link
Member Author

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.

@GuySartorelli GuySartorelli force-pushed the pulls/6/scaffold-sitetree branch from 537dd34 to cd1c06a Compare August 12, 2024 02:11
@GuySartorelli GuySartorelli marked this pull request as ready for review August 12, 2024 02:30
$dependentTable = new LiteralField('DependentNote', '<p></p>');
$this->beforeUpdateCMSFields(function (FieldList $fields) {
$dependentNote = '';
$dependentTable = new LiteralField('DependentNote', '<p></p>');
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
$dependentTable = new LiteralField('DependentNote', '<p></p>');
$dependentTable = LiteralField::create('DependentNote', '<p></p>');

Copy link
Member Author

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.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

];
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>');
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
$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>');

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

Comment on lines 2205 to 2206
$metaFieldDesc = new TextareaField("MetaDescription", $this->fieldLabel('MetaDescription')),
$metaFieldExtra = new TextareaField("ExtraMeta", $this->fieldLabel('ExtraMeta'))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
$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'))

Copy link
Member Author

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'
Copy link
Member

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

Copy link
Member Author

@GuySartorelli GuySartorelli Aug 14, 2024

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).

@GuySartorelli GuySartorelli force-pushed the pulls/6/scaffold-sitetree branch from cd1c06a to c30e89c Compare August 14, 2024 03:07
@emteknetnz emteknetnz merged commit e58c388 into silverstripe:6 Aug 15, 2024
15 checks passed
@emteknetnz emteknetnz deleted the pulls/6/scaffold-sitetree branch August 15, 2024 01:15
GuySartorelli added a commit to creative-commoners/silverstripe-cms that referenced this pull request Aug 15, 2024
emteknetnz pushed a commit to creative-commoners/silverstripe-cms that referenced this pull request Aug 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants