timkelty / craftcms-site-sync

Sync content to locales on element save.
MIT License
40 stars 9 forks source link

Sync doesn't work on matrix #10

Closed angeldevz closed 5 years ago

angeldevz commented 7 years ago

How do we enable sync on matrix?

alex-emslie commented 7 years ago

I too am having this issue. Is it currently not possible with matrix fields?

timkelty commented 7 years ago

It currently doesn't but should after a PR merge https://github.com/timkelty/craft-localesync/pull/9

Should get that merged in shortly

joepagan commented 7 years ago

Just tried @superwick PR from https://github.com/timkelty/craft-localesync/pull/9 didn't work for me unfortunately.

timkelty commented 7 years ago

@lexbi do you have the matrix field flagged as translatable? (as well as whatever fields within your matrix)?

joepagan commented 7 years ago

Yes, both the matrix field & the matrix fields within it.

timkelty commented 7 years ago

Weird. @superwick and idea?

timkelty commented 7 years ago

I'm sorry, I got really confused with 2 separate PRs :)

The PR for matrix support was here: https://github.com/timkelty/craft-localesync/pull/6 and was already merged in with version 1.3.

So if you're on 1.3 and it isn't working, we'll have to see why. @lexbi Can you turn on devMode and see if any errors are logged?

joepagan commented 7 years ago

I certainly can, though I just want to check my settings are right, can you confirm, I'm a bit uncertain what's right?

I want all the locales to take the British version, here are my settings:

image

How do I force a sync? I have tried re-saving an entry, but it doesn't apply anything to the other locales.

Here is a completely fresh log file of trying to save a completely new entry with the slug of trans-6 craft.log.zip using the settings above.

Let me know if I've done anything wrong here.

timkelty commented 7 years ago

@lexbi Seems ok to me. In this case saving a US English entry should sync to British if the content is identical. Are things syncing ok for you with non-matrix fields?

To force a sync (if the content isn't identical), you'd want to make sure the "overwrite" option is enabled.

joepagan commented 7 years ago

Hmm maybe I was expecting it to work in a way which it isn't yet setup for?

It appears that the sync does in fact work, but, only on a non translatable matrix & translatable fields within it. This is the only way that Craft is able to do this at the moment (on first save).

timkelty commented 7 years ago

@lexbi Gotcha. Sounds like I'll have to do more testing with Matrix fields.

Matrix was originally excluded as there wasn't a good way to compare if the content was identical or not. The feature was merged in, but it appears maybe a bit prematurely.

I'll have to do some more testing, it gets confusing really fast :)

Here are the cases we need to decide what happens:

Let me know what you think.

I'm leaning towards the simpler approach where if a matrix field is translatable, syncing will occur for that entire field and it's blocks (if fields are identical or overwrite is on). Anything else gets very complicated to explain or expect what would happen.

Perhaps @erktime or @superwick would like to chime in, I believe they've been using matrix syncing in the wild more than I.

joepagan commented 7 years ago

I think if you are wanting to sync the data, you need to cover all those options.

timkelty commented 5 years ago

This is done in the Craft 3 version: https://github.com/timkelty/craft-site-sync/tree/2.0.0