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

Update support for Silverstripe 5 #55

Merged
merged 4 commits into from
May 17, 2023
Merged

Conversation

chrispenny
Copy link
Collaborator

@chrispenny chrispenny commented Mar 2, 2023

SiteTreeLink no longer saves Page::$Title to Link::$Title

When we're using a SiteTreeLink, then it's quite common for us to want to inherit the Title of the linked Page. Current behaviour is that when you create your Link, the Page::$Title is saved into the Link::$Title. This means that if the Page::$Title changes later down the line, your Link will still have whatever the original Title was.

Updated logic:

  • Added a getTitle() method to SiteTreeLink, which will first return Link::$Title, and fall back to Page::$Title (if possible).
  • Removed the onBeforeWrite(), so we're no longer saving the Page::$Title in our Link model.
  • Added TitleRelField to Link::jsonSerialize(), and updated the JS component to display this as a fall back if no Title was provided.

The outcome is...

In your Link preview, you can see the Title from TitleRelField:
Screen Shot 2023-03-29 at 10 13 10 AM

But in the Edit form, the Title remains empty:
Screen Shot 2023-03-29 at 10 13 03 AM

@chrispenny chrispenny marked this pull request as ready for review May 17, 2023 19:32
@chrispenny
Copy link
Collaborator Author

We've been running this branch on a Silverstripe 5 project for a while now, and haven't had any specific issues. I'll merge this and tag it as 3.0.0-beta1.

@chrispenny chrispenny merged commit 469ad24 into master May 17, 2023
@GuySartorelli GuySartorelli deleted the feature/silverstripe-5 branch March 5, 2024 02:21
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