Publisher does not support the Fluid field type. Please do not contact asking when support will be available.

If you purchased an add-on from expressionengine.com, be sure to visit boldminded.com/claim to add the license to your account here on boldminded.com.

Ticket: Phrases not working in Multiple Site Manager

Status Resolved
Add-on / Version Publisher 2.4.1
Severity
EE Version 3.5.6

Paper and Pixels

Apr 25, 2017

Description:
In a brand-new install of a 3.5.6 MSM set-up I couldn’t initially get phrases to display on the front end. Things seemed to be okay in the control panel, but the phrase would only come through as text (that is, as “{phrase:xxx}”). I checked the database and the SiteID was not being assigned correctly — it would always go in as SiteID=1. If I changed the SiteID in the database to the one that was currently being used (for example, SiteID=3 in my case) the phrases would then render in the templates as expected.

So it looks like the phrases are always being saved for the main site only, and not for the site in which they’re entered. On that point, by the way, the phrases are showing up in the control panel for each site, although I expected that I would be able to maintain a different set of phrases for each site (or, even better, decide on a phrase-by-phrase basis if that phrase should be specific to that site, or global across all sites). Hope that makes sense?

Detailed steps to reproduce the issue:
1. Switch to different MSM site (SiteID≠1)
2. Add phrases and template tags
3. Check front-end: {phrase:xx} shows as text, not rendered
4. Check database: all rows have SiteID=1, not

#1

BoldMinded (Brian)

Hi there. Thanks for the report. If you open the Model/Phrase.php file and go to line 116 and add this it should work. Note that you’ll need to re-save the phrase.

->setSiteId(ee()->config->item('site_id'))

When editing phrases it still shows phrases from all sites. At this time I’m not 100% the best way to handle this b/c it seems on many occasions people want to re-use phrases from site to site.

So adding that line above to save the phrase specific to that site or just removing the site_id from phrases entirely so they’re available across all sites is an option.

#2

Paper and Pixels

Thanks for that. It’s working on that third site now, which is good. I agree that phrases are potentially a bit of a complicated thing. I’m sure that no matter what you end up doing, someone is going to want something different 😉

For now, though, until you decide on and implement a best-practice approach, I think it’s probably best to eliminate the site_id entirely. That is because you’re right on one thing: it’s certainly likely that the vast majority of phrases would be ones that a user would want to make available across all sites. When I first tried to use a phrase on a template I couldn’t do it because the site_id was not correct (1 instead of 3), so it was only working on the first site. The change you’ve just given me is now working by writing in the correct site_id, so the template code is now rendering, but when I need to use that same phrase on other sites I’m going to have to recreate it for each site. And you’re right that most of the phrases would be most useful across all of the sites, so that’s the most important thing. At the moment, though, that doesn’t seem possible?

If you’re happy with that line of thought, what would I have to do to eliminate the site_id entirely? I’m rolling out multiple languages on the site with site_id=3 for now, but later on I’ll be doing that for the other sites as well.

I’m only just starting with Publisher, so apologies if I’m doing things the best way right now. But if we can get this working then I think it’s looking quite promising. And if I will certainly let you know if I run into use cases where there might be some value in working out if other approaches might be of value!

#3

BoldMinded (Brian)

Let me think about this one a bit 😊

#4

Paper and Pixels

Sure thing! I know you’ll come up with something really brilliant 😊

#5

BoldMinded (Brian)

It’ll probably be better to make phrases available on all sites until something better is in place, otherwise if they are assigned to a site it’ll be more difficult to handle it later if my solution does not jive with the current site assignments in the phrases. For now just comment out these lines of code, and remove that patch I posted above.

https://www.dropbox.com/s/fzbj1fjez22z5w0/Screenshot 2017-04-27 10.47.58.png?dl=0

#6

BoldMinded (Brian)

BTW this change will be in the 2.5 release.

#7

Paper and Pixels

Thanks so much. That seems to be working, but I’ve only had time for a quick check — and it does indeed look like it’s now pulling phrases through to the other sites. Had to move on to other things right now, but I’ll try to get back to this over the weekend.

If you don’t hear from me, though, it’s probably good news! 😉

Login to reply