Skip to content

Conversation

@moacode
Copy link

@moacode moacode commented Jun 19, 2019

Use Case

I wanted to be able to set field specific settings per site. I.e., it'd be great to create a bunch of presets (e.g. themes for each site), and toggle that preset on the same field.

What I did

Craft doesn't support multi-site field settings out of the box. The simplest approach I could think of was to simply store the site specific settings in an array key called "siteSettings", and direct Craft to load those ones when required, otherwise falling back to the default settings.

I added a toggle so users can choose whether their color settings will be propagated across all sites, or specific to each site.

I also removed the translation field, as I don't think it's relevant for this field type? (Correct me if I'm wrong!).

How to test

  1. Install plugin
  2. Create some presets
  3. Create multiple sites
  4. Create a colorit field and assign to a section
  5. Test setting a preset on the field, and ensure it's the same between each site.
  6. Now toggle the "Multi-Site" light switch, and ensure you can set individual presets for each site.
  7. Do the same with color palettes.
  8. Ensure the correct colors display on you entries.

(Note: I tested mine inside a matrix).

+ Added an option to choose whether to apply colors across all sites, or keep setting specific to each site.
+ Removed the translation select box.
+ Ensured the “site wide” changes don’t get modified when site specific changes are made.
@michtio
Copy link

michtio commented Apr 23, 2020

Is this going to be reviewed and implemented @samhibberd ?? This is a must have feature.

@samhibberd
Copy link
Contributor

samhibberd commented Apr 23, 2020

Yes absolutely @michtio, field presets / settings might be getting a little restructure which needs to be considered carefully to ensure backwards compatibility, we will implement either way.

Thanks for the pr @thejoshsmith.

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.

4 participants