From 2b0eef18e79a20c14c02ec8116797b2069104f51 Mon Sep 17 00:00:00 2001 From: Steve Boyd Date: Tue, 13 Feb 2024 19:26:32 +1300 Subject: [PATCH] DOC Automatic publishing of linked pages and files --- README.md | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/README.md b/README.md index f96872dc..d0673a44 100644 --- a/README.md +++ b/README.md @@ -186,6 +186,28 @@ class MyCustomLink extends Link Custom links can have validation set using standard [model validation](https://docs.silverstripe.org/en/5/developer_guides/forms/validation/#model-validation). +## Automatic publishing of linked pages and files + +When publishing a link that is either a "Page on this site" or a "Link to a file", the page or file that is linked to will not be automatically published when the link is published. This is to prevent unintentional publishing of draft or modified pages and files. However this does mean that content authors may publish links to unpublished pages or files which will return a 404 when a regular user attempts to use the link. + +The link is itself published when the link's "owner" is published. The links owner is a page or another `DataObject` that the link has been added to as a relation. + +If you wish to have pages and files that are linked to be automatically published when the link is published, then add the following YAML configuration in your project: + +```yml +# "Page on this site" +SilverStripe\LinkField\Models\SiteTreeLink: + owns: + - Page + +# "Link to a file" +SilverStripe\LinkField\Models\FileLink: + owns: + - File +``` + +Read more about [defining ownership between related objects](https://docs.silverstripe.org/en/5/developer_guides/model/versioning/#defining-ownership-between-related-versioned-dataobject-models). + ## Migration from LinkField v3 to v4 The `Title` DB field has been renamed to `LinkText`