doublesecretagency / craft-googlemaps

Google Maps plugin for Craft CMS - Maps in minutes. Powered by the Google Maps API.
https://plugins.doublesecretagency.com/google-maps/
Other
10 stars 9 forks source link

Allow different Addresses per different Sites #11

Open lindseydiloreto opened 3 years ago

lindseydiloreto commented 3 years ago

The Address field should be aware of which Site is being edited. Currently, all Sites share the same Address data.

I believe it's mostly a matter of adding a siteId column to the Address table in the database. We'll find out how true that is once I dive into the task.

This feature is expected to be released as early as v4.1, or as late as v4.3. If anything changes, I'll post back to this thread!


Migrated from Smart Map: https://github.com/doublesecretagency/craft-smartmap/issues/22

AndrewMac commented 2 years ago

Hi Lindsey, good to see you've still got this on the roadmap! I remember we discussed this a while back, when the plugin was still SmartMap. We really need this feature as our sites are mainly English/Thai, and Thai has its own script. The same issue would, of course, come up with China, Japan, the Middle East nations and a host of others.

For example, with the location "Chiang Mai, Thailand" The Thai is เชียงใหม่ ประเทศไทย

Although the location data can be looked up in English, we use the Google Maps address fields (along with some custom fields) to populate the marker popup and the entry page. So we really need the Thai version if possible :-)

Thanks so much for considering this, Andrew

lindseydiloreto commented 2 years ago

Certainly, no problem! I still regard it as one of the more important issues. 🙂

Once some of the 4.1 issues are resolved, I look forward to knocking this out in 4.2.

idawgik commented 2 years ago

I have a project I'm currently working on that could really use this feature. In our case, it's a multi-site where we have location data for each site in a global. Since I can't set the address field as translateable, the location info is shared between both sites (even though they have separate addresses). I would need to look at setting things up differently to make it work as things are now, so getting this support would be a huge plus.

MoritzLost commented 1 year ago

@lindseydiloreto Hey Lindsey, any updates on supporting translation methods / multi-site support? This might become very relevant to an upcoming project. Is this still planned, and if so, is there any kind of ETA you can share?

svondervoort commented 2 months ago

Any update on this? Currently running into the same issue with a multisite and an address field in globals.

lindseydiloreto commented 1 month ago

I believe I finally have this done... Would anyone on this thread care to pull the latest dev version and test it?

"doublesecretagency/craft-googlemaps": "dev-v4-dev"

This is currently only available on Craft 4. Once it is deemed stable, it will be ported to Craft 5.

⚠️ Please make sure to backup your database first, as this update will run a significant migration!


Multisite Support

This update formally introduces multisite support. In other words, an Address can now contain different values for each site in your project.

All standard translation methods are supported.


Once this feature is confirmed to be working and stable on Craft 4, I will tag and release a Google Maps update.

Additionally, I will also port this feature to:

For anyone willing to take it for spin, please let me know once you've run some tests. I'm eager to hear how it goes! 🙏

AndrewMac commented 1 month ago

Hi @lindseydiloreto, that’s great news! Sadly, though, I'm not currently running any Craft 4 sites, and I'm not sure when I might have time to spin one up for testing. I'll try to do that, but with any luck, some of the others will be in a better position than I am.

svondervoort commented 1 month ago

That's great, I have some development research time Friday next week where I can give it a test.

MoritzLost commented 1 month ago

@lindseydiloreto Just gave this a try, looks good to me 👍

Added a small cosmetic comment here, but everything seems to be working: https://github.com/doublesecretagency/craft-googlemaps/commit/c0db6434645fae967439c81a987888e9e39da989#r142853593

One thing to note is that this will multiply the number of rows in the database with the number of sites. As I mentioned on Discord, I think this is the best way, just something to note. Probably useful to mention this in the docs or changelog. Might have performance and storage space implications for sites with tons of addresses and sites.

In theory, it might be possible to leave the site ID empty if the field is set to not be translatable and only save the address once in this case. However, I'm not sure if this will work with the way the address table is joined in modifyElementsQuery. Probably safest not to touch this and just always set the site ID, even if it means duplicating some rows unnecessarily.

lindseydiloreto commented 1 month ago

@MoritzLost Ok great, thanks for testing everything! 🙏

I agree that this table structure (a row for each site) is probably the best approach. It seems to work well with how Craft handles things internally, and is hopefully somewhat future-proof.

Per your advice, I just added a migration warning to both the CHANGELOG and the docs.

Thanks for looking over everything, it's greatly appreciated! 🍺