ExpressionEngine CMS
Open, Free, Amazing

Thread

This is an archived forum and the content is probably no longer relevant, but is provided here for posterity.

The active forums are here.

Enabling Multi-site search: parameters in EE2.1.3

January 11, 2011 3:44pm

Subscribe [3]
  • #1 / Jan 11, 2011 3:44pm

    Jamie Rumbelow

    546 posts

    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_id

    This 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.

  • #2 / Jan 11, 2011 4:44pm

    cpaws

    25 posts

    Thanks for such a quick solution! Unfortunately it’s not working for me.

    When I go to a page where this would be used, I see this error:

    A PHP Error was encountered
    
    Severity: Notice
    
    Message: Array to string conversion
    
    Filename: channel/mod.channel.php
    
    Line Number: 2402
    A PHP Error was encountered
    
    Severity: Notice
    
    Message: Array to string conversion
    
    Filename: channel/mod.channel.php
    
    Line Number: 2442
    A PHP Error was encountered
    
    Severity: Notice
    
    Message: Array to string conversion
    
    Filename: channel/mod.channel.php
    
    Line Number: 2452
    A PHP Error was encountered
    
    Severity: Notice
    
    Message: Array to string conversion
    
    Filename: channel/mod.channel.php
    
    Line Number: 2459
    A PHP Error was encountered
    
    Severity: Warning
    
    Message: Cannot modify header information - headers already sent by (output started at /home/cpaws/public_html/system/codeigniter/system/core/Exceptions.php:170)
    
    Filename: core/Common.php
    
    Line Number: 405
    
    Fatal error: ob_start() [<a href="http://ref.outcontrol">ref.outcontrol</a>]: Cannot use output buffering in output buffering display handlers in /home/cpaws/public_html/system/codeigniter/system/core/Exceptions.php on line 166
  • #3 / Jan 12, 2011 5:39am

    Jamie Rumbelow

    546 posts

    Hi,

    Ooo, that’s weird, it’s working perfectly over here and I can’t replicate those errors. Could you send me all the code in between “Field searching” and “Build sorting clause” so I can have a look? It’s almost certainly my fault, but I do want to be sure.

    Jamie

  • #4 / Jan 12, 2011 9:56am

    cpaws

    25 posts

    Sent you a PM. Cheers!

  • #5 / Jul 28, 2011 11:51am

    judin

    54 posts

    Hi Jamie,

    I’m on the latest version of EE2.2.1 and wonder how I can achieve what you outlined here? It looks as if there may have been some mods to mod.channel.php since you posted your instructions.

    Any help appreciated!

    Thanks,
    Justin

.(JavaScript must be enabled to view this email address)

ExpressionEngine News!

#eecms, #events, #releases