Per-blog search in Movable Type

Posted by unbrand on 10 May 2004 | 0 Comments

It looks like blog-specific search in Movable Type is slightly broken out of the box, at least on the search results page. Let’s say you put some search code on your blog like this: <div class="sidetitle"> Search </div> <div class="side"> <form method="get" action="<$MTCGIPath$><$MTSearchScript$>"> <input type="hidden" name="IncludeBlogs" value="<$MTBlogID$>" /> <label for="search" accesskey="4">Search this site:</label><br /> <input id="search" name="search" size="20" /><br /> <input type="submit" value="Search" /> </form> </div> It works great, and is blog-specific because of the <$MTBlogID$> bit above. You can even use this on an Apache-level 404 ErrorDocument if you just replace the 3 Movable Type variables above with the values you care about. An easy way to figure those out are to do a View Source on the MT-rendered page. So what’s the problem? The search results page itself has a search widget that does not include the <$MTBlogID$> bit. So that means if you do any searches at that point, MT will search all the blogs on your site. And MT may not grab the css you want it to when the results are rendered. To fix this, go to your (MT cgi-bin-dir)/search_templates directory. In there is a file called default.tmpl. Just add the line: <input type="hidden" name="IncludeBlogs" value="<$MTBlogID$>" /> above the line <input type="text" size="30" name="search" value="<$MTSearchString$>" /> <input type="submit" value="Search" /><br/><br /> and you’ll be all set.

Related: Elise has a good thread on options for escaping markup text.

Post your comment

Comments

No one has commented on this page yet.

RSS feed for comments on this page