February 20, 2003
- updated February 23, 2003
The MovableType
search function, mt-search.cgi, returns search result as a single
long list of entries. The version 1.2 of MTPaginate
plugin introduced support for a CGI mode which allows you to use it in a search_results template.
Make sure that you follow these directions
when adding MTPaginate tag to your templates.
- <form method="get">
An HTML form can be submitted in two different ways as specified by the method attribute.
- <MTPaginate mode="cgi">
Be defauly the MTPaginate tags generate PHP code that gets executed by the
server when a browser retrieves the page. Since searching a blog invokes
the mt-search.cgi, the server does not execute any PHP code in the page
returned by the CGI so you must specify mode="cgi" so that the MTPaginate
tags generate static text instead of PHP code.
- <MTPaginateNavigator>
In order to be able to navigate to other pages, you should have a <MTPaginateNavigator>
tag in your search template. Look at the MTPaginate
documentation for additional
options.
Please note that the MTPaginate plugin is free for personal use, but requires
a $20
license for commercial use.
Paginated Search Template
The template that is used to generate the search results is stored in the
MovableType/search_templates directory. The default template is called
default.tmpl - you can replace it with the following template which displays
ten entries per page. You may want to modify this template, especially the
div.pageselector style or the <MTPaginateNavigator> tag. You can download
this template from this location: default.tmpl.
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Search Results</title>
<link rel="stylesheet" href="<$MTBlogURL$>styles-site.css" type="text/css" />
<style type="text/css">
<!--
div.pageselector
{
margin-bottom: 1em;
}
div.pageselector a,
div.pageselector a:link,
div.pageselector a:visited
{
TEXT-DECORATION: none
}
div.pageselector a:hover,
div.pageselector a:focus,
div.pageselector a:active
{
TEXT-DECORATION: underline
}
-->
</style>
</head>
<body>
<div id="banner">
<h1><a href="<$MTBlogURL$>">Search Results</a></h1>
</div>
<div id="container">
<div class="blog">
<MTPaginate mode="cgi">
<MTPaginateIfMultiplePages>
<div class="blogbody"><div class="pageselector">
Results <b><MTPaginateTopSection></b> - <b><MTPaginateBottomSection></b> of <MTPaginateNumSections>:
<MTPaginateIfAllPages_><b>[ <MTPaginateNumPages> ]</b><MTPaginateElse_><a href="<$MTPaginateAllPagesLink$>"
title="Show all results in one page"><MTPaginateNumPages></a></MTPaginateIfAllPages_> Pages:
<MTPaginateIfPreviousPage_>
<a href="<MTPaginatePreviousPageLink>"><</a>
<MTPaginateElse_>
<
</MTPaginateIfPreviousPage_>
<MTPaginateNavigator separator=" " format_current=" <b>[ %d ]</b> ">
<MTPaginateIfNextPage_>
<a href="<MTPaginateNextPageLink>">></a>
<MTPaginateElse_>
>
</MTPaginateIfNextPage_>
</div>
</MTPaginateIfMultiplePages>
<MTPaginateContent max_sections="10">
<MTSearchResults>
<MTBlogResultHeader>
<h2 class="date">Search Results from <$MTBlogName$></h2>
<MTElse>
<MTPaginateIfPageHeader_>
<h2 class="date">Search Results from <$MTBlogName$></h2>
</MTPaginateIfPageHeader_>
</MTElse>
</MTBlogResultHeader>
<div class="blogbody">
<h3 class="title"><a href="<$MTEntryLink$>#<$MTEntryID pad="1"$>"><$MTEntryTitle$></a></h3>
<$MTEntryExcerpt$> <$MTEntryEditLink$><br />
<div class="posted">Posted in <$MTBlogName$> on <$MTEntryDate$></div>
</div>
<MTPaginateSectionBreak>
</MTSearchResults>
</MTPaginateContent>
</MTPaginate>
<MTNoSearchResults>
<h2 class="date">Searched for "<$MTSearchString$>"</h2>
<div class="blogbody">
<p>No pages were found containing "<$MTSearchString$>".</p>
</div>
</MTNoSearchResults>
<MTNoSearch>
<h2 class="date">Instructions</h2>
<div class="blogbody">
<p>By default, this search engine looks for all words in any order.
To search for an exact phrase, enclose the phrase in quotes:</p>
<blockquote><pre>"movable type"</pre></blockquote>
<p>The search engine also supports AND, OR, and NOT keywords to specify boolean expressions:</p>
<blockquote><pre>personal OR publishing</pre></blockquote>
<blockquote><pre>publishing NOT personal</pre></blockquote>
</div>
</MTNoSearch>
<form method="get" action="<$MTCGIPath$><$MTSearchScript$>">
<h3 class="title">Search this site:</h3>
<div class="comments-body">
<input type="text" size="30" name="search" value="<$MTSearchString$>" />
<input type="submit" value="Search" /><br/><br />
<input type="checkbox" name="CaseSearch" />
Match case <input type="checkbox" name="RegexSearch" /> Regex search<br/><br />
</div>
</form>
</div>
</div>
</body>
</html>