Store section defaults in addon settings #511
Open
ryanmitchell wants to merge 3 commits intostatamic:7.xfrom
Open
Store section defaults in addon settings #511ryanmitchell wants to merge 3 commits intostatamic:7.xfrom
ryanmitchell wants to merge 3 commits intostatamic:7.xfrom
Conversation
Member
|
Thanks for the pull request! 🙌 This looks good from a quick glance but I'll need to carve out some time to review this probably, so it might be a week or two until I'm able to take a look. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Section defaults (the SEO configuration set per-collection or per-taxonomy) were previously stored as
inject.seoinside each collection or taxonomy's YAML file. This works fine in a standard Statamic setup, but when using the Eloquent driver in split-config mode — where YAML holds structural config and the database holds content — those files get overwritten on each deployment, wiping any customised section defaults.This PR moves section defaults storage to addon settings, the same place site defaults already live as of v7. When using the Eloquent driver, addon settings can be stored in the database, so they survive deployments.
What's changed
Storage
Section defaults are now stored under
section_defaultsin the addon settings file (resources/addons/seo-pro.yamlor equivalent). The format is flat for single-site installs and nested under asiteskey for multi-site:Existing inject.seo data
Existing data in collection/taxonomy YAML files is still read as a fallback — nothing breaks on upgrade. The migration happens lazily: the first time you save a section's defaults through the CP, the old inject.seo value is removed from the YAML and the data is written to addon settings instead. If you'd rather migrate everything at once rather than waiting for each section to be touched, you can do so by opening and saving each section in the CP.
Per-site defaults and origin inheritance
Section defaults now support per-site values with origin inheritance, matching how site defaults work. Origins for section defaults are configured independently of site defaults (stored under section_defaults_sites), so you can have different inheritance structures for each.
UI
The section defaults edit page now has a site switcher and a Configure button (in multi-site setups) for setting which site each locale inherits from, consistent with the site defaults UI.
Disabled state
Setting a section to disabled applies globally across all sites, same as before.