February 17, 2007
- updated March 5, 2007
The built-in MovableType search allows you to search entries and/or comments for user-specified text. However, you have no control over which parts of your entries and comments are searched and when listing search results using the built-in template tags, it is only possible to display the entry, regardless whether its text or that of a comment was matched by the search terms.
The MTSearchPlus plugin enhances the search capabilities in two ways. First, it lets you specify which parts of your entry (i.e. title, text, text_more, keywords) and comment (i.e. text, auther, url) it searches through. Second, it enables your search results to list whether an entry’s text or specific comment(s) were matched by the search term. Finally, it only searches visible comments and ignores those pending approval or marked as junk.
This plugin reimplements two internal MovableType functions and may break in future versions of MovableType. It has been tested with MT 3.2 and 3.33.
Search Results Template Tags
Returns the version of the MTSearchPlus plugin.
Container tags (used within MTSearchResults) whose contents are displayed only if the current entry’s text matched the search terms.
Container tag (used within MTSearchResults) which iterates over the comments in the current entry matched by the search terms. It sets up the context for each matched comments allowing you to use all the appropriate MTComment* tags.
Maximum number of comments to display in a search result entry. The default value is no limit.
- sort_order=”ascend” or “descend”
Specifies the sort order of the comment listings. The default value is set in the blog’s General Settings.
Tag (used within MTSearchResults) which displays the number of comments in the current search results entry that were matched by the search terms.
Conditional tag (used within MTSearchResults) which is TRUE if the current search results entry’s text was matched by the search term.
Conditional tag (used within MTSearchResults) which is TRUE if one or more of the current search results entry’s comments were matched by the search term.
Modifying your Search Form
After installing this plugin, you can specify which parts of an entry and comment are searched by modifying your search form to include SearchField controls that specify which fields are to be searched. Valid SearchField values are title, text text_more , keywords, comment-text, comment-author and comment-url.
To specify that only entry titles are searched, add the following to your search form:
<input type="hidden" name="SearchField" value="title">
If you want to let the user choose which fields to search, you could use check box controls (if the users leaves all unchecked, every field in each entry will be searched):
<input type="checkbox" name="SearchField" value="title" /> Search Titles
<input type="checkbox" name="SearchField" value="text" /> Search Text
<input type="checkbox" name="SearchField" value="text_more" /> Search Extended Text
<input type="checkbox" name="SearchField" value="keywords" /> Search Keywords