angell-co / Pimp-My-Matrix

A plugin for Craft that lets you enhance a busy Matrix field and organise block types
MIT License
60 stars 5 forks source link

Locale support? #47

Closed brettgullan closed 6 years ago

brettgullan commented 8 years ago

Hi there,

I'm using PMP on a multi-lingual Craft site and found that the field-level PMP overrides don't work on the non-default locales.

So, for instance, I've added a Matrix field to an Entry type and configured it using the Group block types option. That configuration works fine for the default (English) locale. But for the other language, only the plugin-level settings appear.

Is this something that could be fixed in a future version?

Many thanks,

Brett

joshangell commented 8 years ago

Hi @brettgullan - in short, yes it probably can, but I'm unlikely to do it - mostly due to time. Clients have to come first sadly!

I'll leave this open as a FR though and someone may pick it up and make a PR, for which I would be grateful.

All the best,

Josh

brettgullan commented 8 years ago

Hey @joshangell,

Thanks for that; I've finally had a chance to dig in to the PMP code, and it seems the issue is generally pretty simple ...

In the loader() function of PimpMyMatrixService.php, the segment-based conditions for loading the Matrix field manipulation don't allow for the locale segment (from line no. 128).

I've only done limited testing so far, but line #130 needs to be changed to allow 3 or more segments (for Entries):

      if ( count($segments) >= 3 && $segments[0] == 'entries' )

Globals are slightly trickier, as the inclusion of a locale segment is different, but the premise is the same.

I'll work on nutting it out properly and submit a PR.

Cheers,

Brett

joshangell commented 8 years ago

Excellent - thanks!

joshangell commented 6 years ago

Fixed in #48 for Craft 3.