Git Product home page Git Product logo

craftcms-site-sync's Introduction

Site-Sync

Synchronize content between sites in a multi-site Craft CMS installation.

Motivation

In a multi-site configuration, translatable field content is propagated to other sites only on initial save. If you want to edit translatable content and propagate those changes to your other sites, you have to recreate the changes on each site. ๐Ÿคข

Site-Sync allows you to propagate and sychronize changes on a per-field basis, whenever you save an element. In addition to any field content (including Matrix, et al.), it can also sync title and slug content, as those are always translatable in Craft.

Unlike the Craft 2 version and other similar plugins, this plugin is implemented as a field for a few key reasons:

  • It works when saving an element in the HUD.
  • Multiple fields can be created with different default settings.

Installation

$ composer require timkelty/craftcms-site-sync

Usage

Each field layout where you would like to perform syncing must contain a Site-Sync Settings field.

Site-Sync Settings Field

In the field settings you can configure the default state of the field. Note, that unlike most fields, changes to this field do not persist between element saves. They will always revert to the state configured in the field settings.

Site-Sync Settings Field

When you save an entry with a Site-Sync Settings field:

  • If the Enabled toggle is on when you save an element, content that matched before saving will be propagated to the other sites.
  • Only content from the selected Sources will be synchronized.
  • Content will only be propagated to sites where the user has permission to save elements.

Nesting (Matrix, Neo, SuperTable, et al.)

When any element (e.g. MatrixBlock, Entry) is saved, the plugin will traverse up its hierachy (via ElementInterface::getParent) until it finds a Site-Sync Settings field.

For example, this means you can have a single Site-Sync Settings field on your Entry layout, but a nested MatrixBlock will still find it and use those settings for syncing.

This also means (if you want to get crazy), that you could include a Site-Sync Settings field on a MatrixBlock to limit the scope of the syncing to that block only. Or, you could include one on the Entry layout and override it with another on a MatrixBlock layout. While this approach is supported, it can get exponentially confusing for the user and likely isn't practical for most uses.

Roadmap

  • Plugin store
  • Validate field layouts to only allow 1 of this field type
  • Value/label usability improvements (toggleLabelId)
  • Fix compatibility with CP Field Links
  • Change "Title" name if there is a custom.
  • Implement getElementValidationRules to add errors to the element
  • Ensure elements are only saved when they have pending changes (performance)

craftcms-site-sync's People

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.