One of the users of Taggable, my tagging module, wanted to be able to search tags across sites. As Taggable primarily uses ExpressionEngine’s in-built searching system to locate tags, this meant that I had to solve the age-old problem to fix multisite-wide search: parameters. I’ve also included quick developer notes to explain whats going on in italics. Feel free to skip these bits if case you’re not interested.
The fix is pretty simple, but it does require modifying core code. If any developers can figure out a way around this, please let me know. Before you apply this fix, remember to back up the files in case something goes wrong. You know how much I like saying ‘I told you so’.
Step One
Open up system/expressionengine/modules/channel/mod.channel.php in a text-editor of your choice. Skip right down to line 2397, create a newline, and paste the following code:
foreach ($this->EE->TMPL->site_ids as $site_id)
{Scroll down, to what should now be line 2488, create a newline, and paste:
}When the MSM is installed and enabled, Template.php parses out the site=”” parameter automatically and puts the site IDs in an array($site_name => $site_id]) called $this->EE->TMPL->site_ids. We loop through them to check for each field in each site, as some sites may have the field and others may not.
Step Two
Between these two lines (2397 and 2488), replace every occurrence of this:
$this->EE->config->item('site_id')With this:
$site_idThis should be on lines 2400, 2415, 2424, 2428, 2433, 2469, 2478 and 2482.
We’re substituting the current site ID for the current iterated site from the list provided. This is pretty easy, because the custom fields are already arranged by site ID and if no site is provided the current site is set. Thus making this a simple exercise of find and replace!
And you’re done!
So, that was quite a few changes, but it’s a simple replacement. Just make sure you don’t touch anything else while you’re in there otherwise it’ll be pandemonium. I would post the entire snippet here, but I don’t want to expose the innards of EE to anyone who hasn’t paid (unless I get permission from EL).
I hope this has helped you and do let me know how you get on!
Jamie, from Sparkplugs.