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

DOC Document new CMSEditLink extension. #85

Merged

Conversation

GuySartorelli
Copy link
Member

@GuySartorelli GuySartorelli commented Sep 13, 2022

@GuySartorelli GuySartorelli force-pushed the pulls/4/canonical-edit-link branch 2 times, most recently from f931340 to 48ef5a2 Compare September 16, 2022 01:08
@GuySartorelli GuySartorelli changed the title DOC Document new HasCanonicalEditLink trait. DOC Document new CMSEditLink trait. Sep 16, 2022
@GuySartorelli GuySartorelli force-pushed the pulls/4/canonical-edit-link branch 2 times, most recently from 991517a to 353eff5 Compare September 19, 2022 23:23
@GuySartorelli GuySartorelli force-pushed the pulls/4/canonical-edit-link branch from 353eff5 to 2621b64 Compare September 26, 2022 22:10
@GuySartorelli GuySartorelli changed the title DOC Document new CMSEditLink trait. DOC Document new CMSEditLink extension. Sep 27, 2022
@GuySartorelli GuySartorelli force-pushed the pulls/4/canonical-edit-link branch from 2621b64 to be6cd68 Compare September 29, 2022 22:20

When using this extension, your model must also declare its `cms_edit_owner` as a
[configuration property](../configuration/configuration/#configuration-properties). The value must either be the class name of the
`ModelAdmin` that directly manages the record, or the `has_one` relation for the record that this model is edited on.
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
`ModelAdmin` that directly manages the record, or the `has_one` relation for the record that this model is edited on.
`ModelAdmin` that directly manages the record, or the `has_one` relation for the record that this model is edited on, which is often the parent DataObject

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


## Getting an edit link

To get a link for editing a record, other than some exceptions like `SiteTree`, you have historically had to generate the link mostly
Copy link
Member

Choose a reason for hiding this comment

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

I don't think we need to provide a historical background. The docs we provide are always for the latest version. Unfortunately we don't contain docs for older minor versions, though that's just a limitation of our documentation system, and not something we should attempt to handle here

Copy link
Member Author

Choose a reason for hiding this comment

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

Removed.

If the `cms_edit_owner` is a `has_one` relation, the class on the other end of the relation _must_ have
a reciprocal `has_many` relation as documented in [Relations](./relations#has-many). For best results, use dot notation on the
`has_many` relation. It must also implement a [getCMSEditLinkForManagedDataObject()](api:SilverStripe\Admin\CMSEditLinkExtension::getCMSEditLinkForManagedDataObject())
method. The easiest way to do that is for it to have `CMSEditLinkExtension` applied as well.
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
method. The easiest way to do that is for it to have `CMSEditLinkExtension` applied as well.
method. The easiest way to do that is for it to apply the `CMSEditLinkExtension` to the reciprocal class.

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


[hint]
If the `cms_edit_owner` is in some vendor dependency that you don't control, you can always apply `CMSEditLinkExtension`
and the `cms_edit_owner` via yaml.
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
and the `cms_edit_owner` via yaml.
and the `cms_edit_owner` via yml.

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


### New `CMSEditLinkExtension`

The silverstripe/admin module has a new [CMSEditLinkExtension](api:SilverStripe\Admin\CMSEditLinkExtension) which makes it trivial to generate an edit link for any `DataObject` even in nested `GridField` setups. This is useful, for example, when [making a previewable `DataObject`](/developer_guides/customising_the_admin_interface/preview/) or as links in reminder emails for stale content.
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
The silverstripe/admin module has a new [CMSEditLinkExtension](api:SilverStripe\Admin\CMSEditLinkExtension) which makes it trivial to generate an edit link for any `DataObject` even in nested `GridField` setups. This is useful, for example, when [making a previewable `DataObject`](/developer_guides/customising_the_admin_interface/preview/) or as links in reminder emails for stale content.
The `silverstripe/admin module` has a new [CMSEditLinkExtension](api:SilverStripe\Admin\CMSEditLinkExtension) which is used to generate CMS edit links for `DataObject`s, including those in nested `GridField` setups.
This allows you to share DataObject edit links directly with others. This extension is also used to facilitate CMS preview of DataObjects

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

@GuySartorelli GuySartorelli force-pushed the pulls/4/canonical-edit-link branch from be6cd68 to 2c45760 Compare September 30, 2022 00:13
@emteknetnz emteknetnz merged commit cee7cc8 into silverstripe:4 Sep 30, 2022
@emteknetnz emteknetnz deleted the pulls/4/canonical-edit-link branch September 30, 2022 02:11
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