Searching Groups Of Blogs 1.0

December 13, 2003 - updated February 8, 2006

The MovableType search forms allow you to limit which Blogs to search by specifying IncludeBlogs and/or ExcludeBlogs one blog ID at a time. This means that for every blog you want to specify, there has to be a checkbox or hidden input field. This hack modifies MovableType so that you can specify more than one blog ID with an Include/ExcludeBlogs parameter. This allows you, for example, to present the user with a single checkbox or menu item that allows them to search through mutlitple blogs.

lib/MT/App/ Modification

This modification allows you to specify more than one blog ID (separated by comma) in the IncludeBlogs and ExcludeBlogs fields of a search template.
  1. Open the file in the lib/MT/App directory.
  2. Find the code that says:
            for my $blog_id ($q->param($type)) {
                $app->{searchparam}{$type}{$blog_id} = 1;
  3. Replace it with thefollowing code:
    	# BEGIN Searching Groups Of Blogs HACK
            for my $blog_ids ($q->param($type)) {
                for my $blog_id ( split /\s*,\s*/, $blog_ids) {
                    $app->{searchparam}{$type}{$blog_id} = 1;
    	# END Searching Groups Of Blogs HACK

Modifying your Search Form

After you modify the file, you can modify your search form to include multiply BlogIDs in IncludeBlogs and ExcludeBlogs fields. The following code displays a menu with three option, each of which will search through different blogs:
<select name="IncludeBlogs">
    <option value="1,2,3">All blogs</option>
    <option value="2,3">Art blogs</option>
    <option value="1">Journal</option>
    <option value="2">Photos</option>
    <option value="3">Drawings</option>