Recent Topics

Search in all Blogs

Started by on Sep 15, 2004 – Contents updated: Sep 15, 2004

Sep 15, 2004 23:32    

Hi!

Is there a possibility to search in more than one blog from a search box? Currently the search does only include the current blog but not my other ones.

Any idea? Thanks a lot.

Michael

Sep 16, 2004 00:04

Here's what I use on my blog.

Put this in your _main.php file, or wherever the search box is located:

Code

<form method="get" class="search" action="<?php
      $savedBlog = $Blog;
      $savedblog = $blog;
      unset($Blog);
      $blog = 1;
      bloginfo('blogurl');
      $Blog = $savedBlog;
      $blog = $savedblog ?>">
    <input type="text" name="s" size="18" value="<?php echo htmlspecialchars($s) ?>" />
    <select name="sentence">
      <option value="AND" selected="selected">All Words</option>
      <option value="OR">Some Word</option>
      <option value="SENTENCE">Exact Phrase</option>
    </select>
    <input type="submit" name="submit" value="<?php echo T_('Search') ?>" />
    </form>
It's important to handle both $Blog (the object) and $blog (the number). This will search all blogs.

Sep 16, 2004 00:35

It works! Thanks a lot!

Seem to have only one problem: The selection "Exact phrase" seems not to work. It finds the same as "All words".

I tried to set the varible in lower case letters so it reads "sentence" instead of "SENTENCE" and then it seems to work!?

Mar 14, 2005 15:45

Issac, I also was trying to search all my blogs and tried your method, but it didn't work for me. Do you happen to know what else may be the problem. Thanks.

Aug 07, 2005 02:16

isaac wrote:

Here's what I use on my blog.

Put this in your _main.php file, or wherever the search box is located:

Code

<form method="get" class="search" action="<?php
      $savedBlog = $Blog;
      $savedblog = $blog;
      unset($Blog);
      $blog = 1;
      bloginfo('blogurl');
      $Blog = $savedBlog;
      $blog = $savedblog ?>">
    <input type="text" name="s" size="18" value="<?php echo htmlspecialchars($s) ?>" />
    <select name="sentence">
      <option value="AND" selected="selected">All Words</option>
      <option value="OR">Some Word</option>
      <option value="SENTENCE">Exact Phrase</option>
    </select>
    <input type="submit" name="submit" value="<?php echo T_('Search') ?>" />
    </form>
It's important to handle both $Blog (the object) and $blog (the number). This will search all blogs.

What do you mean by handle? What should be changed? Can you provide an example? Let's say I want to search Blog 6, 8 and 10.

Thanks for your help!


Form is loading...

multiple blogs – This forum is powered by b2evolution CMS, a complete engine for your website.