WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] Multisite Search? (16 posts)

  1. Noel Forte
    Member
    Posted 1 year ago #

    If I wanted to do a multi-site search, is there any possible way to do something like this?

  2. I've not tried it myself but this was the first hit in my Google search.

    http://wordpress.org/extend/plugins/multisite-global-search/

    Apparently there are others as well.

    http://wordpress.org/extend/plugins/search.php?q=multisite+search

  3. Noel Forte
    Member
    Posted 1 year ago #

    Alright, I've gone through everything in google and the plugin respiratory. Thank you kindly for the suggestions.

    Any other ideas?

  4. Roy
    Member
    Posted 1 year ago #

    I tried that first plugin a year ago, but couldn't get it working. I might need to try again, but first check what MySQL is installed on my server.

    Back then I tried a few others without succes and ended up using Google which I am relatively happy with. See Gangleri.nl and the 'search entire website' option in any of the subsites (books, films, music, )

  5. Noel - What errors did you have? :) Or what didn't work the way you wanted and how?

    Knowing where it didn't meet the mark helps us adjust aim ;)

  6. Roy
    Member
    Posted 1 year ago #

    Mika, I don't think that Noel already tried the plugin, she was out for a multisite search option. Back in the days (...) I couldn't get it working, but I haven't tried it since.

  7. Noel said he(?) went through everything in Google. So ... what didn't meet the criteria? :) I mean, if you go through everything you find and nothing meets the need, what need is it missing...

    It's a bold assumption. (You I know, couldn't get it working, but if you still need help, make a new topic for that ;) Which you know.)

  8. Roy
    Member
    Posted 1 year ago #

    Ah no, I'm fine thank you :-)
    Let's see if Noel still needs help indeed.

  9. Noel Forte
    Member
    Posted 1 year ago #

    Yes I'm a guy , and i was considering perhaps using google custom search to deliver results. What I'm basically looking for is a way to search over multiple blogs an display the results on a seperate page.

  10. http://wordpress.org/extend/plugins/multisite-global-search/ should do that. I tested and it seems to work just fine.

  11. Roy
    Member
    Posted 1 year ago #

    Sorry Noel, I didn't pay enough attention...
    Anyway, you've got several hints above, the plugin that is mentioned a few times and that seems to work well (I'll have to try it again myself some time). Google search is an option. See Google for more info.
    http://www.google.com/cse

    Try both and let us know when something goes different than expected.

  12. Noel Forte
    Member
    Posted 1 year ago #

    OK, so I've got the multisite plugin working. Unfortunately, when I implement the code onto my page, the browser returns the following errors.

    Implemented this:
    <?php Multisite_Global_Search::ms_global_search_horizontal_form('search-results') ?>

    Returned this:

    Warning: Missing argument 2 for Multisite_Global_Search::ms_global_search_vertical_form(), called in /home/noelfo5/public_html/wp-content/themes/fortissimo/homepage.php on line 40 and defined in /home/noelfo5/public_html/wp-content/plugins/multisite-global-search/inc/class.widgets.php on line 109
    
    Warning: Missing argument 3 for Multisite_Global_Search::ms_global_search_vertical_form(), called in /home/noelfo5/public_html/wp-content/themes/fortissimo/homepage.php on line 40 and defined in /home/noelfo5/public_html/wp-content/plugins/multisite-global-search/inc/class.widgets.php on line 109
  13. Noel Forte
    Member
    Posted 1 year ago #

    Fixed it. Thanks for all your help.

  14. jnwb
    Member
    Posted 1 year ago #

    Hi Noel - I'm getting the same two error messages as you with the multisite search plugin. Do you remember how you fixed it?

    Thanks

  15. Noel Forte
    Member
    Posted 1 year ago #

    Hi jnwb,

    Here's the fix: (and an explanation)

    In this case, the solution is actually in the error message. If we open up our file "class.widgets.php" which you can find by going toi the path dictated in the warning, we see the following on lines 109-137.

    function ms_global_search_vertical_form( $page, $search_pages, $hide_options ) {
    		if( isset( $this ) ) {
    		    $id_base = $this->id_base;
    		} else {
    		    $id_base = 'ms-global-search';
    		}
    
    		$rand = rand(); $rand2 = $rand + 1; ?>
    		<form class="ms-global-search_form" method="get" action="<?php echo get_bloginfo( 'wpurl' ).'/'.$page.'/'; ?>">
                <input id="s" class="field" name="mssearch" type="text" placeholder="Search across network sites:" size="16" tabindex="1" />
                <input type="submit" id="searchsubmit" class="button submit" value="<?php _e( 'Search', 'ms-global-search' )?>" tabindex="2" />
    	    </form>
    	<?php
    	}
    
    	function ms_global_search_horizontal_form( $page, $search_pages, $hide_options ) {
    		if( isset( $this ) ) {
    		    $id_base = $this->id_base;
    		} else {
    		    $id_base = 'ms-global-search';
    		}
    
    		$rand = rand(); ?>
    	    <form class="ms-global-search_form" method="get" action="<?php echo get_bloginfo( 'wpurl' ).'/'.$page.'/'; ?>">
                <input id="s" class="field" name="mssearch" type="text" placeholder="Search across network sites:" size="16" tabindex="1" />
                <input type="submit" id="searchsubmit" class="button submit" value="<?php _e( 'Search', 'ms-global-search' )?>" tabindex="2" />
    	    </form>
    	<?php
    	}

    The above code might look a bit different than your own; I hacked the plugin and inserted the WordPress search form as the return for the search form instead of the multisite one, this way it styles the same in your CSS as it was intended in your theme.

    These two functions are what control the php code that you called. ( <?php Multisite_Global_Search::ms_global_search_horizontal_form('search-results') ?> However, when you compare your php to the function that the php is calling, you might notice something odd.

    Remember, this is what you put in:

    <?php Multisite_Global_Search::ms_global_search_horizontal_form('search-results') ?>

    and the function looks like this:

    function ms_global_search_vertical_form( $page, $search_pages, $hide_options )

    So what we have here is a line of PHP code that calls a function which demands $page, $search_pages, and $hide_options as input arguments, but in our code, we only provided one, "search-results" as our $page, hence the "missing argument on line 109".

    So to fix this, let's provide the function in the "class.widgets.php" file with two additional arguments, whether we want to search pages, and whether we want to show the options.

    My final markup looked like this:

    <?php Multisite_Global_Search::ms_global_search_vertical_form('search-results','','hide_options'); ?>

    Notice I left the $search_pages option blank. You can do this, and the plugin will default to a value of 0, and not search pages. If you would like to include pages in your search, set it to 1.

    Kinda a long way around just for one line of code, but I hope the explanation was useful. If you have more questions, don't hesitate to ask.

    PS. I didn't like how this plugin worked, there were a few quirks to get by. If you dig through the plugin files, you could figure out what everything does and hack it to your liking. After all that's the purpose of plugins, right? Open source for the win.

    Hope this helped,

    Noel

  16. jnwb
    Member
    Posted 1 year ago #

    Thanks so much Noel - that's extremely helpful!

Topic Closed

This topic has been closed to new replies.

About this Topic