We use cookies to improve your experience. No personal information is gathered and we don't serve ads. Cookies Policy.

ExpressionEngine Logo ExpressionEngine
Features Pricing Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University
Log In or Sign Up
Log In Sign Up
ExpressionEngine Logo
Features Pro new Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University Blog
  • Home
  • Forums

How do I make a plugin MSM compatible?

Development and Programming

Aaron Fowler's avatar
Aaron Fowler
113 posts
14 years ago
Aaron Fowler's avatar Aaron Fowler

I have a small EE2 plugin that queries the exp_entry_titles and exp_relationships tables. What do I need to do (if anything) to make it MSM compatible? I couldn’t find anything in the docs.

Thanks, Aaron

       
Adrian Macneil's avatar
Adrian Macneil
21 posts
14 years ago
Adrian Macneil's avatar Adrian Macneil

Probably nothing, but it really depends what your plugin does. Do you have a github link or anything? Or at least post some example usage of your plugin.

Usually, if you are only querying channels you are fine, at least in most situations, since channels are unique to each site.

       
Aaron Fowler's avatar
Aaron Fowler
113 posts
14 years ago
Aaron Fowler's avatar Aaron Fowler

Github link for Familee: https://github.com/aaronfowler/familee.ee2_addon

Thanks!

       
johndwells's avatar
johndwells
94 posts
14 years ago
johndwells's avatar johndwells

Hi Aaron,

If you take a look at the exp_channel_titles table, you’ll see a column labeled “site_id”; this is present for both MSM-enabled and non-MSM sites. When not running MSM, then the only site is the “default_site”, and the site_id is always going to be 1.

There’s also an exp_sites table should you be curious; again this exists even if MSM is not installed or being used.

So it is then always the case that whenever you get the EE object, you can retrieve the current site_id with:

$EE =& get_instance();
echo $EE->config->item('site_id');

Having said all of that, I don’t believe you need to do anything to your plugin; your only required parameter, “entry_id” is unique to the exp_channel_titles table, so you do not run the risk of inadvertently retrieving erroneous relationships from other sites.

However if you were to amend your plugin to also accept a url_title as a lookup, then you would need to modify your query to take the current site_id into account.

That was a bit of a rushed response, but hope it helps!

Cheers, John

       
Aaron Fowler's avatar
Aaron Fowler
113 posts
14 years ago
Aaron Fowler's avatar Aaron Fowler

Very helpful - thanks, John and Adrian

       

Reply

Sign In To Reply

ExpressionEngine Home Features Pro Contact Version Support
Learn Docs University Forums
Resources Support Add-Ons Partners Blog
Privacy Terms Trademark Use License

Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.