Pagination is plugin for Movable Type that enables you to paginate lists of entries. For example, at the bottom of your home page, you could add a "Next" link so your readers can go to "Page 2" and read previous entries. You can display a list of linked page numbers to enable visitors to jump to any page number they want.

With Pagination Pro, you can also paginate your Category, Author, and date-based archives, and even paginate your Entry archives, displaying only a small number of comments on each page.

Try it Now - Live Demo

The MT4 Test Blog has the Pagination Pro plugin enabled. Scroll to the bottom of the home page to see the list of pages and follow the links. Also take a look at an example of a paginated Category archive here. Finally, take a look at a paginated version of a 300+ comment entry here.

How it Works

My goal here was to create a pagination plugin with high performance. I didn't want it to slow down rebuilds, and I wanted pages to display for readers without delay. With these goals in mind, I decided to dynamically render pages 2, 3, 4, and so on. This means that unlike the default for most pages in Movable Type, pages 2+ are not static files that get published to your blog directories. They dynamically rendered by the plugin's page viewer script. Note that this viewer script is Perl-based and does not use MT's built-in PHP-based dynamic publishing system. The benefit of this is that you can virtually any plugin template tags in your paginated templates, and you don't need to use PHP. So when someone views page 2, the script goes into action and builds the page and displays it.

Paginated URLs are clean, ending in index.html?page=2 (or similar). Pagination makes use of mod_rewrite for Apache to keep these URLs clean (most MT sites run on Apache, but there may be some alternative approaches for other web servers).

Page-Level Caching

To speed up dynamic page views and reduce CPU/memory/database usage, Pagination supports (optional) page-level caching, powered by the Cache Block plugin. This means that once the plugins generates the HTML for "page 2", it will store that in the cache for next time. And next time someone wants to see "page 2", it can be quickly fetched from the cache. In my tests, dynamic page views from the cache took about 0.04 seconds, so this is very fast. In the plugin settings you can specify how long to cache pages before refreshing the cache.

Template Tags

Pagination comes with a template module that makes it easy to implement -- in most cases you can simply include the module in your existing templates and it will 'just work'. So you may not need to learn or use the template tags below. But if you want to customize the appearance of your Pagniation links, you can use/edit the following tags:

  • <mt:PaginationPages> - This is a container tag for displaying linked page numbers, previous / next page links, etc. This tag should only be placed inside the following containers: <mt:EntriesFooter>, <mt:EntriesHeader>, <mt:CommentsFooter>, and <mt:CommentsHeader>. There are several arguments:
    • max_pages - (Required) The maximum number of page numbers to display at one time. Note that page numbers will roll forward as readers view higher page numbers, just like Google paginated search results.
    • glue - (Optional) This should contain some text or symbols that you to display bewteen each page number. For example, if you want 1 - 2 - 3, then use glue=" - ".
    • lastn - (Required) The number of items shown on each page. This must match the lastn argument of the parent <mt:Entries> or <mt:PaginatedComments> tag.
    • archive_type - (Optional) For advanced use, you can use this tag to override the archive_type used to calculate the page numbers and links. If omitted, the plugin will use the archive_type of the page being built.
    • class_type - (Optional) For advanced use, this tag will override the type of MT object being counted to determine the number of pages.
  • <mt:PaginationPageNumber> - Used inside a <mt:PaginationPages> container, this tag will display the page number being processed in the loop (not the current page number that is being published/viewed).
  • <mt:PaginationPageLink> - Used inside a <mt:PaginationPages> container, this tag will display the URL to page number being processed in the loop.
  • <mt:IfPreviousPage> - Conditional tag that is true if the page being displayed is 2 or higher.
  • <mt:PaginationPreviousPageLink> - The URL to the previous page.
  • <mt:IfNextPage> - Conditional tag that is true if the currently viewed page is not the last page.
  • <mt:IfNotLastPage> - Conditional tag that is relative to the page being processed, not the page being viewed - returns true if the page being processed is not the final page.
  • <mt:LastPageLink> - The URL to the last page.
  • <mt:LastPageNumber> - The number of the last page.
  • <mt:PaginatedComments> - (Pro only) This is replacement container tag for <mt:Comments>. If you want to paginate the list of comments on an Entry archive, you should use <mt:PaginatedComments> instead of <mt:Comments>. You can use all the same <mt:Comment_____> tags inside the container. Arguments include:
    • show - The number of comments to show per page. (Note that you can also use 'lastn' for this argument)
    • offset - The offset for the page of comments. This should always be set to "$pagination_offset".

Templates Set

Pagination comes with two templates:

  • Pagination - A template module that can be included in other templates to display page links.
  • HTACCESS for Pagination - An index template that builds the required mod_rewrite rules. Important: The output file for this template has been set to "htaccess.txt" on purpose. Some sites have already have a ".htaccess" file and you want to be careful not to overwrite the existing one (for example, if you use MT's PHP dynamic publishing, with my Fast Search plugin or otherwise). Check to see if you already have an .htaccess file and if you do, you may want build this template as "htaccess.txt" and then copy and paste the rules into the appropriate place in your .htaccess file (if using MT's dynamic publishing, paste before the existing rules.) If you want to use this template to build your .htaccess file, you will need to change the output file to ".htaccess".

Requirements

Note: while not required, the Cache Block plugin is needed if you want to use the Pagination caching features.

Installation

  1. Download the zip file and upload the contents of the 'plugins' folder to the 'plugins' directory of your MT installation.
  2. Change the permissions of the /plugins/Pagination/pages.cgi script to 755 (CHMOD 755).
  3. Go to the blog you want and then to Preferences > Plugins and then open the settings for the Pagination plugin. Enable the caching settings if desired, then Save.
  4. Return to the settings and click the "Install Templates" button. This will install the templates mentioned above.
  5. Setup your .htaccess file with the Pagination rules, as described above.
  6. Edit your Main Index template and add the following before the </MTEntries> tag:

    <mt:EntriesFooter>
    <mt:Include module="Pagination">
    </mt:EntriesFooter>

  7. Modify your <MTEntries tag to include the argument offset="$pagination_offset". This is important. Example: <MTEntries lastn="10" offset="$pagination_offset">

  8. (Pro only) Do the same for your "Entry Listing" archive template, for both MTEntries containers.

  9. (Pro only) If you want to paginate your comment listings on your Entry archives, edit the "Comments" template module to replace the <MTComments> container with the MTPaginatedComments container, as discussed above. Be sure to include show="10 offset="$pagination_offset".

Get Pagination Pro

Commercial License for 1 to 10 blogs - $97

Blog Network License for 10+ blogs - $249

Personal License for 1 to 4 blogs - $33

Get Pagination

Pagination is free for personal or commercial use, but you must leave the "powered by" link, which is added automatically below the paginations links.

Download Now

Download Now
Downloads: 1618

Membership required, please sign-in or register:

As always, comments, questions, and suggestions are welcome.

Fast Search is a PHP plugin for Movable Type. This means that Fast Search uses Movable Type's dynamic PHP-based publishing system to display search results. However, you can continue to use static publishing for all of your indexes and archives. Fast Search is fast in part because it uses mySQL fulltext indexing -- basically this means that a search index will be created for the entries in your database, making searches much faster. Like the built-in search, Fast Search logs searches to the Movable Type Activity log.

Update 3/11/2007:Version 2.02 has been released. This is a critical update for those who installed 2.0 prior to March 10, 2007. Inadvertently, the old version of the MTSearchString tag was included in that zip file. Version 2.02 has the correct version of that tag. Note: if you don't plan on using Tag Search, then you don't really need 2.02.
Update 3/14/2007:Version 2.03 has been released. This version addresses a Unknown column 'mt_entry.entry_id' in 'on clause' error that affected people running mySQL 5+. (A big thanks to David Chiu for providing the fix!)

New Features in Version 2.0

Fast Search v2.0 has several new features:

  • Tag Search. Fast Search now supports Tag Search (MT3.3+). Also known as a tag listing, Tag Search displays a list of entries with a specific tag. If you list tags in your entries, they are probably linked to a Tag Search. Fast Search v2.0 does the same thing, only faster.
  • Better Relevance Ranking. Fulltext searches now provide much better relevance ranking.
  • Easier System-wide Searching. Now it is even easier to to search all blogs in a single search.
  • Search results containing all keywords. This is a small change for Fulltext searches. Previously, if you searched for 'red books' (without quotes), the search results would include any entry containing 'red' or 'books'. In version 2.0, only entries with both 'red' and 'books' will be included in the search results. This makes things more consistent with other search engines.
  • Fast Search Widget. A new Fast Search Widget makes it easy to add a Fast Search form to your sidebar.
  • New Template Tags. Several new template tags make it easier to customize your search results. Fast Search now supports all of the template tags used in the default MT 3.3 search results template -- this means it is even easier to switch to Fast Search

Tag Searches with Fast Search

Fast Search now supports tag search. A tag search will display a list of all entries with a specific tag. Of course, tag searches have the same pagination features as regular searches, enabling you to browse multiple pages of tag search results. Tag search results are always sorted with the most recent entries listed first. Tag searches can done on a single blog (default), or across multiple blogs.

Tag Search Links. If you are using tags with MT 3.3+, you are probably displaying a list of tags with each entry. Each of those tags are linked to a search results page that displays all the entries with that tag. Since those links point to the built-in mt-search.cgi script -- Fast Search includes a new version of the <MTTagSearchLink> tag that points to the Fast Search script. This happens automatically, you don't have to edit your templates -- just enable Fast Search, install the Fast Search template, then rebuild your pages -- the tag links will be automatically updated.

Clean Tag Search URLs

With Fast Search 2.0, it is possible to use nice looking tag search URLs such as:

http://mt-hacks.com/tag/spam
http://mt-hacks.com/tag/comments

This feature requires editing you .htaccess file and a minor edit to the Dynamic Bootstrapping template. This feature is only available to those who purchase a license or those personal users who donate at least $33. I will email you the required files and full instructions.

Better Relevancy

By tweaking the fulltext queries, I have managed to improve the relevancy ranking significantly. To test this out, you should do a few searches (in fulltext mode) before you upgrade to Fast Search 2.0 -- note the results and their relevancy -- then upgrade and do the same searches. You should see much more relevant results at the top of the search results. Please post your feedback on this by replying to this entry.

Search all Blogs Easier

In the previous version of Fast Search, it was possible to search across all blogs on a system, but you had to specify each of them separated by commas. This is fine if you have a few blogs, but what if you have 50? 100? 500? Version 2.0 makes this easier by allowing the special "all" keyword to indicate that you want to search all blogs (example <MTSearchResults blogs="all"> or in the URL/form: ?query=books&blogs=all). A time-saver for large MT installations and blog networks.

Include PHP in your Search Results Template

This not a new feature, but it deserves highlighting. Many sites use PHP on most of their pages for various reasons (for example, to include content such as headers/footer and advertising blocks). The problem is that you can't use PHP on the "built-in" search results pages, because they are dislayed by a (Perl) CGI script. This can make it challenging to maintain your site in a consistent manner. You can avoid such problem with Fast Search -- since it is powered by PHP, you can include blocks of PHP code in the search results template. (Note: there is a small requirement that you need to use <?php to start each block, using simply <? won't work.)

What Search Method is Best?

For most cases, "Fulltext" will be the fastest search method. This is the same method used in version 1.0. There are some cases in which you might two options:

  • Non-Fulltext. Technically speaking this method used a LIKE %query% syntax. If you don't know what that means, don't worry about, just read on.
  • Fallback. The Fallback method is a combination method. FastSearch will first try a fulltext search, and if that returns no results, then it will try a Non-Fulltext search.

Non-Fulltext and Fallback are capable of some types of searches that you can't do with mySQL. You might want to use Non-Fulltext or Fallback to:

  1. search multi-byte languages such as Arabic and Japanese.
  2. search words shorter than 3 characters (such as "MTV")
  3. search partial words
  4. search a mySQL database that does not support Fulltext searching

Template Tags

Version 2.0 of FastSearch is designed to easily replace the existing search functionality in Movable Type, but with added features. For example, if you are currently using customized search templates, you can use them with Fast Search, with very few changes in most cases. Many Fast Search template tags have the same names as their CGI counterparts:

  • <MTSearchString> - The search string (query) being searched.
  • <MTSearchResults> - A container tag that displays search results. Arguments include (all are optional):
    • lastn - restricts the search to n results. (example <MTSearchResults lastn="10"> ) The lastn argument, like all arguments for MTSearchResults, can also be specified in the URL (...&lastn=10) or POSTed from a search form)
    • offset - used in coordination with lastn, starts M entries from the start of the list. (example <MTSearchResults lastn="10" offset="10"> will display results 11-20)
    • order - must be either 'date' or 'relevance', the default is 'relevance'. (example $lt;MTSearchResults order="date"> will provide similar results as the CGI search)
    • category - must be a valid category ID for the current blog - restricts the search results to entries from this category.
    • google_highlight - if specified, search words will be highlighted. (example <MTSearchResults google_highlight="1"> )
    • query - the search string (text) to be searched. In normal use, you would NOT include this argument as part of the <MTSearchResults> tag, rather, it would be specified as a URL paramter (example ...query=search+phrase) or POSTed from a search form.
    • new - tag - the tag to be searched. In normal use, you would NOT include this argument as part of the <MTSearchResults> tag, rather, it would be include as a URL parameter (example ...tag=books) as part of a Tag Search Link.
    • blogs - a comma-separated list of blog_ids if you want to search more than one blog. This argument is optional, if excluded, only the current blog will be searched. Example usage: <MTSearchResults blogs="1,3,8">new - Set blogs equal to "all" to search every blog on the sytem.
  • <MTBlogResultHeader> - this is container tag that displays content before the search results.
  • <MTBlogResultFooter> - this is container tag that displays content below the search results.
  • <MTNoSearchResults> - A container tag that displays its content only if zero results are found. Note that this tag must be used after a <MTSearchResults> container.
  • <MTNoSearch> - A container conditional tag that displays its content only if no search phrase was specified. new - Now supports the use of <MTElse> inside this container.
  • <MTSearchCount> - The number of search results displayed on the current search results page. This tag should be used with a <MTBlogResultHeader> or <MTBlogResultFooter> container.
  • <MTSearchFirst> - The number of the first search result on the current page. This tag should be used with a <MTBlogResultHeader> or <MTBlogResultFooter>container.
  • <MTSearchLast> - The number of the last search result on the current page. This tag should be used with a <MTBlogResultHeader> or <MTBlogResultFooter>container.
  • <MTSearchIfNextPage> - A conditional tag that displays its content if there is a subsequent page of search results. This tag should be used with a <MTBlogResultHeader> or <MTBlogResultFooter>container.
  • <MTSearchNextPageLink> - Output a URL to the next page of search results. This tag should be used within <MTSearchIfNextPage> tags.
  • new - <MTSearchIfPreviousPage> - A conditional tag that displays its content if there is a previous page of search results. This tag should be used with a <MTBlogResultHeader> or <MTBlogResultFooter>container.
  • new - <MTSearchPreviousPageLink> - Output a URL to the previous page of search results. This tag should be used within <MTSearchIfNextPage> tags.
  • <MTSearchTotalResults> - The total number of matching results in the database.
  • <MTSearchPages> - A container tag that can display links to multiple pages of search results. Optional arguments include:
    • max - the maximum number of page links to display on each page. Example: <MTSearchPages max="20">
    • glue - a text string that seperates each page. For example, if you wanted to display 1 - 2 - 3 - 4, you could use <MTSearchPages glue=" - ">
  • <MTSearchPageNumber> - Displays the page number of each search results page. This must be used within a <MTSearchPages> container.
  • <MTSearchPageLink> - Displays the URL to each search results page. This must be used within a <MTSearchPages> container.
  • <MTSearchIfCurrentPage> - A conditional tag that only displays its contents if the page number is the same as the current page - you would normally use this is you wanted to highlight the current page in the list of page numbers, etc. This must be used within a <MTSearchPages> container.
  • new - <MTIfStraightSearch> - A conditional tag that only displays its contents if the search is a normal search and not a tag search.
  • new - <MTIfTagSearch> - A conditional tag that only displays its contents if the search is a tag search and not a normal search.
  • new - <MTFastSearchScript> - This tag displays the filename of your Fast Search script. You can use this in your search forms as shown below. Note: for this tag to work, you should not rename your Fast Search template -- it should laways be named "Fast Search". This tag works in both static and dynamic templates.
  • replacement - <MTTagSearchLink> - This tag overrides the built-in tag of the same name (this automatic, not need to edit templates or anything). The new version of the tag is "smart" -- if Fast Search is enabled for a blog, it will link to the tag search results using the Fast Search script -- if not, it will use the built-in search script. This tag has the following optional argument:
    • tag_dir - Use this argument to specify a "directory" name for your tag search URLs. Note: This feature is only available to personal users who make a donation OR those who buy a commercial license.

Note: the new default Fast Search template includes pre-formatted template code that displays Google-style search results page links.

As you may have noticed, some of the tags above are identical to the ones used for the existing CGI-based search results. This is by design, so you will easily be able to cut-and-paste your existing search template code into the Fast Search template, though some minor modifications may be required.

Working Examples:

Here are some working examples you can try. Feel free to try additional search queries and note the speed that searches are performed.

  • Tag search results on MT Hacks. Example tags: spam cms.
  • Mars Rover Blog has over 5,000 entries. Example search: "water on mars". Note that this example shows the default FastSearch template, which is very similar to the default search results template in MT 3.2.
  • Seinfeld Blog has over 8,000 entries, 180 of which consist of the episode descriptions and scripts of all 180 episodes. Fast Search powers the Seinfeld Script Search, which is restricted to a single category containing the episodes. Example search: 'bubble boy'

Requirements:

  • Movable Type 3.2 or 3.3
  • mySQL

Instructions

  1. Download the plugin and expand the zip file.
  2. Upload the contents of the 'plugins' folder to the 'plugins' directory of your MT installation (usually something like /cgi-bin/mt/plugins).
  3. Upload the contents of the 'php' folder to the 'php' directory (usually something like /cgi-bin/mt/php)
  4. Login to the MT admin interface. If you already logged in, choose 'Main Menu'
  5. If your are running MT 3.3, you should be redirected to an 'Upgrade' screen at this point. The Fast Search upgrade process will update your database to add a fulltext index to the table in your database where entries are stored. Note that this may take some time if you have many entries, and this will add to the overall size of your database.
  6. If you are running MT 3.2, you will not see the upgrade screen (as it is a 3.3 feature), so you need to create the index by browsing to the 'Settings' of a blog where you want to use Fats Search. Choose the 'Plugins' tab then find 'Fast Search' and choose 'Settings'. Now click the link in bold that says "Click here to create or rebuild the FastSearch fulltext index". Again, this may take some time, please be patient. After the index has been created, hit the Back button.
  7. Now browse to the 'Publishing' settings tab for the blog, and scroll down to the Setting called "Dynamic Publishing". If the first option, "Build all templates statically", is selected, you should change this setting to "Set each template's Build Options separately" and click "Save Changes" at the bottom of the screen. Otherwise, you don't need to make any changes here.(Note that change this setting will create an .htaccess file in the root path of the blog. Normally you won't notice this and everything will work fine, but if you have an existing.htacces file, you may want to take a look at it to make sure everything looks okay)
  8. If you just changed your Dynamic Publishing settings in the previous step, you should now rebuild all files for this blog by choosing "Rebuild Site" from the left menu, then "Rebuild all Files". You should also ensure that you have a "Dynamic Site Bootstrapper" (mtview.php) index template and make sure that it gets built, if it hasn't been built previously.
  9. Now return to the Fast Search settings ('Plugins' tab within 'Settings') and check the box to enable Fast Search. You may also want to adjust the settings for Maximum Search Results and logging, then click "Save Changes".
  10. Open the Fast Search settings once again and choose "Click here to install the default Fast Search Template." The template will be created and then displayed. This is an dynamic Index template (which can be customized) used to display the search results. (If desired you can also skip this step and create the index template manually, use the template tags as desired, or by cutting and pasting your exisiting search template code)
  11. Upgrading Fast Search

    Follow steps 1 to 3 above, then adjust your Fast Search plugin settings and search template, if desired. If you using Tag Search, you probably want to update your Fast Search template. One way to do this is to rename or delete your existing template, then reinstall the new default template from the plugin settings area.

The Search Form

If you already have search forms on your blog pages, you need to update them to point to the new Fast Search template. For each template that contains a search form, look for the following (or similar):

<form method="post" action="<$MTCGIPath$><$MTSearchScript$>"

...and change it to:

<form method="post" action="<$MTBlogURL><$MTFastSearchScript>"

...save the template and repeat this step for every template that has a search form.

If you want to insert a new search form on your site, or completely replace existing forms, you can use the following:

<form method="get" action="<$MTBlogURL$><$MTFastSearchScript>">
    <label for="query" accesskey="4">Search this blog:</label><br />
    <input id="query" name="query" size="20" />
    <input type="submit" value="Search" />
</form>

Or better yet, install the new Fast Search Widget from the plugin settings area, and use WidgetManager to add the widget to your sidebar (you should also remove the existing search widget).

Of course you can also add optional fields to the form such as:

<input type="hidden" name="order" value="date" />

....to sort the results by date, or....

<input type="hidden" name="category" value="5" />

...to restrict the search to category_id = 5.

Once you have the search form(s) on you site, rebuild those pages and start searching. You should notice significant speed and resource improvement, especially on blogs with many entries.

Fast Search Settings

Fast Search settings are on a "per blog" basis. To access the settings, browse to the blog you want to use, then choose "Settings", then "Plugins". Look for Fast Search in the list and click the "Show Settings" button.

Download Fast Search

Non-commercial use - FREE ( although you must include a

Movable Type search results powered by 
<a href="http://mt-hacks.com/fastsearch.html">Fast Search</a>
link on your search results pages.

Also, donations are appreciated. Those who donate at least $33 will receive the BONUS "clean tag URLs" feature described above:

Commercial use - (up to 5 blogs) - $97.00

Blog Network License - (more than 5 blogs) - $249.00

Download Now

Download Now
Downloads: 4783 (since 3/6/07)

Membership required, please sign-in or register:

As always, suggestions and feedback are appreciated. Please reply to this entry.

Note: FastSearch v2.0 is a suitable replacement for most implementations of the built-in search function in Movable Type. However, there are a few features that Fast Search v2.0 does not include. Fast Search v2.0 does not support comment searches, regexp search, case-senstive search, the use of AND and OR operators, and Edit Entry Links). Some of these features may be supported in future versions -- please let me know what features you would like to see.

Fast Search is a PHP plugin for Movable Type. This means that Fast Search uses Movable Type's dynamic PHP-based publishing system to display search results. However, you can continue to use static publishing for all of your indexes and archives. Fast Search is fast in part because it uses mySQL fulltext indexing -- basically this means that a search index will be created for the entries in your database, making searches much faster. Like the built-in search, Fast Search logs searches to the Movable Type Activity log.

New Features in Version 1.5

Fast Search v1.5 has several new features:

  • Search Method Options. Three methods are available which control how the searches are conducted. Most users will use the default "Fulltext" option, but some installations will beneft from the two new options. More details below.
  • Multi-Byte Language Support. Fast Search can now search entries with languages in multi-byte languages, such as Arabic and Japanese, using the "Non-Fulltext" search method.
  • Total Number of Results Found. A new tag for displaying the total number of results in the database, so you can display "showing 1 - 10 of 256 results".
  • Search Page Links. Display linked page numbers to link directly to multiple pages of search results.
  • Previous Page Link. Links to the previous page of search results.
  • Short Words Searching. Using the "Non-Fulltext" or "Fallback" search methods, you can now search for words under 4 characters in length.
  • Match Partial Words. Search for partial words using the "Non-Fulltext" or "Fallback" methods, you can now search for partial words.
  • "Mixed" Multi-blog Searching. You can now search multiple blogs in the same search. The results are "mixed" together, in one list of search results, not grouped by blog.

What Search Method is Best?

For most cases, "Fulltext" will be the fastest search method. This is the same method used in version 1.0. There are some cases in which you might two options:

  • Non-Fulltext. Technically speaking this method used a LIKE %query% syntax. If you don't know what that means, don't worry about, just read on.
  • Fallback. The Fallback method is a combination method. FastSearch will first try a fulltext search, and if that returns no results, then it will try a Non-Fulltext search.

Non-Fulltext and Fallback are capable of some types of searches that you can't do with mySQL. You might want to use Non-Fulltext or Fallback to:

  1. search multi-byte languages such as Arabic and Japanese.
  2. search words shorter than 3 characters (such as "MTV")
  3. search partial words
  4. search a mySQL database that does not support Fulltext searching

Template Tags

Version 1.5 of FastSearch is designed to easily replace the existing search functionality in Movable Type, but with added features. For example, if you are currently using customized search templates, you can use them with Fast Search, with very few changes in most cases. Many Fast Search template tags have the same names as their CGI counterparts:

  • <MTSearchString> - The search string (query) being searched.
  • <MTSearchResults> - A container tag that displays search results. Arguments include (all are optional):
    • lastn - restricts the search to n results. (example <MTSearchResults lastn="10"> ) The lastn argument, like all arguments for MTSearchResults, can also be specified in the URL (...&lastn=10) or POSTed from a search form)
    • offset - used in coordination with lastn, starts M entries from the start of the list. (example <MTSearchResults lastn="10" offset="10"> will display results 11-20)
    • order - must be either 'date' or 'relevance', the default is 'relevance'. (example $lt;MTSearchResults order="date"> will provide similar results as the CGI search)
    • category - must be a valid category ID for the current blog - restricts the search results to entries from this category.
    • google_highlight - if specified, search words will be highlighted. (example <MTSearchResults google_highlight="1"> )
    • query - the search string (text) to be searched. In normal use, you would NOT include this argument as part of the <MTSearchResults> tag, rather, it would be specified as a URL paramter (example ...query=search+phrase) or POSTed from a search form.
    • blogs - a comma-separated list of blog_ids if you want to search more than one blog. This argument is optional, if excluded, only the current blog will be searched. Example usage: <MTSearchResults blogs="1,3,8">
  • <MTBlogResultHeader> - this is container tag that displays content before the search results.
  • <MTBlogResultFooter> - this is container tag that displays content below the search results.
  • <MTNoSearchResult> - A container tag that displays its content only if zero results are found. Note that this tag must be used after a <MTSearchResults> container.
  • <MTNoSearch> - A container tag that displays its content only if no search phrase was specified.
  • <MTSearchCount> - The number of search results displayed on the current search results page. This tag should be used with a <MTBlogResultHeader> or <MTBlogResultFooter> container.
  • <MTSearchFirst> - The number of the first search result on the current page. This tag should be used with a <MTBlogResultHeader> or <MTBlogResultFooter>container.
  • <MTSearchLast> - The number of the last search result on the current page. This tag should be used with a <MTBlogResultHeader> or <MTBlogResultFooter>container.
  • <MTSearchIfNextPage> - A conditional tag that displays its content if there is a subsequent page of search results. This tag should be used with a <MTBlogResultHeader> or <MTBlogResultFooter>container.
  • <MTSearchNextPageLink> - Output a URL to the next page of search results. This tag should be used within <MTSearchIfNextPage> tags.
  • new - <MTSearchIfPrevioustPage> - A conditional tag that displays its content if there is a previous page of search results. This tag should be used with a <MTBlogResultHeader> or <MTBlogResultFooter>container.
  • new - <MTSearchPreviousPageLink> - Output a URL to the previous page of search results. This tag should be used within <MTSearchIfNextPage> tags.
  • new - <MTSearchTotalResults> - The total number of matching results in the database.
  • new - <MTSearchPages> - A container tag that can display links to multiple pages of search results. Optional arguments include:
    • max - the maximum number of page links to display on each page. Example: <MTSearchPages max="20">
    • glue - a text string that seperates each page. For example, if you wanted to display 1 - 2 - 3 - 4, you could use <MTSearchPages glue=" - ">
  • new - <MTSearchPageNumber> - Displays the page number of each search results page. This must be used within a <MTSearchPages> container.
  • new - <MTSearchPageLink> - Displays the URL to each search results page. This must be used within a <MTSearchPages> container.
  • new - <MTSearchIfCurrentPage> - A conditional tag that only displays its contents if the page number is the same as the current page - you would normally use this is you wanted to highlight the current page in the list of page numbers, etc. This must be used within a <MTSearchPages> container.

Note: the new default Fast Search template includes pre-formatted template code that displays Google-style search results page links.

As you may have noticed, some of the tags above are identical to the ones used for the existing CGI-based search results. This is by design, so you will easily be able to cut-and-paste your existing search template code into the Fast Search template, though some minor modifications may be required.

Working Examples:

Here are some working examples you can try. Feel free to try additional search queries and note the speed that searches are performed.

  • Mars Rover Blog has over 5,000 entries. Example search: "water on mars". Note that this example shows the default FastSearch template, which is very similar to the default search results template in MT 3.2.
  • Seinfeld Blog has over 8,000 entries, 180 of which consist of the episode descriptions and scripts of all 180 episodes. Fast Search powers the Seinfeld Script Search, which is restricted to a single category containing the episodes. Example search: 'bubble boy'

Requirements:

  • Movable Type 3.2 or 3.3
  • mySQL

Instructions

  1. Download the plugin and expand the zip file.
  2. Upload the contents of the 'plugins' folder to the 'plugins' directory of your MT installation (usually something like /cgi-bin/mt/plugins).
  3. Upload the contents of the 'php' folder to the 'php' directory (usually something like /cgi-bin/mt/php)
  4. Login to the MT admin interface. If you already logged in, choose 'Main Menu'
  5. If your are running MT 3.3, you should be redirected to an 'Upgrade' screen at this point. The Fast Search upgrade process will update your database to add a fulltext index to the table in your database where entries are stored. Note that this may take some time if you have many entries, and this will add to the overall size of your database.
  6. If you are running MT 3.2, you will not see the upgrade screen (as it is a 3.3 feature), so you need to create the index by browsing to the 'Settings' of a blog where you want to use Fats Search. Choose the 'Plugins' tab then find 'Fast Search' and choose 'Settings'. Now click the link in bold that says "Click here to create or rebuild the FastSearch fulltext index". Again, this may take some time, please be patient. After the index has been created, hit the Back button.
  7. Now browse to the 'Publishing' settings tab for the blog, and scroll down to the Setting called "Dynamic Publishing". If the first option, "Build all templates statically", is selected, you should change this setting to "Set each template's Build Options separately" and click "Save Changes" at the bottom of the screen. Otherwise, you don't need to make any changes here.(Note that change this setting will create an .htaccess file in the root path of the blog. Normally you won't notice this and everything will work fine, but if you have an existing.htacces file, you may want to take a look at it to make sure everything looks okay)
  8. If you just changed your Dynamic Publishing settings in the previous step, you should now rebuild all files for this blog by choosing "Rebuild Site" from the left menu, then "Rebuild all Files". You should also ensure that you have a "Dynamic Site Bootstrapper" (mtview.php) index template and make sure that it gets built, if it hasn't been built previously.
  9. Now return to the Fast Search settings ('Plugins' tab within 'Settings') and check the box to enable Fast Search. You may also want to adjust the settings for Maximum Search Results and logging, then click "Save Changes".
  10. Open the Fast Search settings once again and choose "Click here to install the default Fast Search Template." The template will be created and then displayed. This is an dynamic Index template (which can be customized) used to display the search results. (If desired you can also skip this step and create the index template manually, use the template tags as desired, or by cutting and pasting your exisiting search template code)
  11. Upgrading from Fast Search v1.0

    Follow steps 1 to 3 above, then adjust your Fast Search plugin settings and search template, if desired.

The Search Form

If you already have search forms on your blog pages, you need to update them to point to the new Fast Search template. For each template that contains a search form, look for the following (or similar):

<form method="post" action="<$MTCGIPath$><$MTSearchScript$>"

...and change it to:

<form method="post" action="<$MTBlogURL>fastsearch"

...save the template and repeat this step for every template that has a search form.

If you want to insert a new search form on your site, or completely replace existing forms, you can use the following:

<form method="get" action="<$MTBlogURL$>fastsearch">
    <label for="query" accesskey="4">Search this blog:</label><br />
    <input id="query" name="query" size="20" />
    <input type="submit" value="Search" />
</form>

Of course you can also add optional fields to the form such as:

<input type="hidden" name="order" value="date" />

....to sort the results by date, or....

<input type="hidden" name="category" value="5" />

...to restrict the search to category_id = 5.

Once you have the search form(s) on you site, rebuild those pages and start searching. You should notice significant speed and resource improvement, especially on blogs with many entries.

Fast Search Settings

Fast Search settings are on a "per blog" basis. To access the settings, browse to the blog you want to use, then choose "Settings", then "Plugins". Look for Fast Search in the list and click the "Show Settings" button.

Download Fast Search

Non-commercial use - FREE ( although you must include a

Movable Type search results powered by 
<a href="http://mt-hacks.com/fastsearch.html">Fast Search</a>
link on your search results pages.

Also, donations are appreciated:

Commercial use - $97.00

Download Now

Download Now
Downloads: 4783 (since 3/6/07)

Membership required, please sign-in or register:

As always, suggestions and feedback are appreciated. Please reply to this entry.

Note: FastSearch v1.5 is a suitable replacement for most implementations of the built-in search function in Movable Type. However, there are a few features that Fast Search v1.5 does not include. Fast Search v1.0 does not support comment searches, regexp search, case-senstive search, the use of AND and OR operators, and Edit Entry Links). Also, Fast Search v1.5 does not inlcude MT 3.3 search features such as tag search. Some of these features may be supported in future versions -- please let me know what features you would like to see.

Note: There was a major bug in v1.5 that is fixed in this version. If you are using v1.5, you must upgrade to v1.7.

Smart Rebuild v1.7 provides several new features, including:

  • rebuild "chunking" of category rebuilds. When you rebuild your categories, they will get rebuilt in chunks, similar to the way Indvidual Archives get rebuild, a certain number at a time. Of course, this includes the category rebuilding optimizations from Smart Rebuild v1.0. This new chunking feature will be especially helpful for blogs that have many categories (40 or more, in most cases).
  • background rebuilding of category and date-based archives when a new comment is posted. This reduces the amount of time that it takes to post a comment.
  • background rebuilding when items are created, edited, junked, or deleted from the Movable Type admin interface. This means less time waiting when you conduct these tasks.

Note that background tasks will not reduce the server load nor the actual time it takes for pages to be rebuilt. The benefit of background tasks is that the rebuilding is done "in the background", meaning that the process of posting a comment, saving an entry, junking comments, or other task can continue without waiting for the rebuild to complete. In short, it saves time for commenters, authors, and blog admins.

Requirements

MT 3.3x

Note: This version of Smart Rebuild is not suitable for use on MT4+.

Installation Instructions:

  • Download the plugin and upload to the 'plugins' directory in your Movable Type installation.
  • Check to see if background tasks will work on your server. To check, you can use a test script that comes with MT. Go to http://www.yourmtdomain/cgi-bin/mt/mt-tesbg.cgi (modify this address so that it points to the file in your MT directory). If you get message that says "Background tasks are available", then you can turn on this option (see the next step). If background tasks are not available, you should not enable it, as it may cause errors.
  • If you haven't done so previously, turn on background tasks by adding the following line to your mt-config.cgi file:

    LaunchBackgroundTasks 1

Download Smart Rebuild

Non-commercial use - FREE

Commercial use - $97.00

Download Now

SmartRebuild.zip

Membership required, please sign-in or register:

As always, suggestions and feedback are appreciated. Please reply to this entry.

Update, Oct. 9, 2006 - A newer version of Fast Search has been released. Click here for details.

The built-in search tool in Movable Type can be slow and can take a lot of processing power, especially if you have blogs with many entries. When I recently upgraded to version 3.31 of MT, I was dismayed to learn that searches became slower and more processor-intensive (at least on my server). I was forced to disable the mt-search.cgi script, as it was overloading my dedicated server. So I went looking for an alternative. I found a PHP mySQL Fulltext method that worked very fast, and without the CPU problems.

So contacted IƱaki, the creator of this PHP solution, who granted me permission modify the solution and package it up as a Movable Type plugin. I have added a number of features, and I have made significant efforts to make the plugin easy to install and use.

Fast Search is a PHP plugin for Movable Type. This means that Fast Search uses Movable Type's dynamic PHP-based publishing system to display search results. However, you can continue to use static publishing for all of your indexes and archives. Fast Search is fast in part because it uses mySQL fulltext indexing -- basically this means that a search index will be created for the entries in your database, making searches much faster.

Template Tags

Version 1.0 of FastSearch is designed to easily replace the existing search functionality in Movable Type. For example, if you are currently using customized search templates, you can use them with Fast Search, with very few changes in most cases. Many Fast Search template tags have the same names as their CGI counterparts:

  • <MTSearchString> - The search string (query) being searched.
  • <MTSearchResults> - A container tag that displays search results. Arguments include (all are optional):
    • lastn - restricts the search to n results. (example <MTSearchResults lastn="10"> ) The lastn argument, like all arguments for MTSearchResults, can also be specified in the URL (...&lastn=10) or POSTed from a search form)
    • offset - used in coordination with lastn, starts M entries from the start of the list. (example <MTSearchResults lastn="10" offset="10"> will display results 11-20)
    • order - must be either 'date' or 'relevance', the default is 'relevance'. (example $lt;MTSearchResults order="date"> will provide similar results as the CGI search)
    • category - must be a valid category ID for the current blog - restricts the search results to entries from this category.
    • google_highlight - if specified, search words will be highlighted. (example <MTSearchResults google_highlight="1"> )
    • query - the search string (text) to be searched. In normal use, you would NOT include this argument as part of the <MTSearchResults> tag, rather, it would be specified as a URL paramter (example ...query=search+phrase) or POSTed from a search form.
  • <MTBlogResultHeader> - this is container tag that displays content before the search results. (Note: in version 1.0 of Fast Search, you cannot search multiple blogs in the same search)
  • <MTBlogResultFooter> - this is container tag that displays content below the search results.
  • <MTNoSearchResult> - A container tag that displays its content only if zero results are found. Note that this tag must be used after a <MTSearchResults> container.
  • <MTNoSearch> - A container tag that displays its content only if no search phrase was specified.
  • <MTSearchCount> - The number of search results displayed. This tag should be used with a <MTBlogResultHeader> or <MTBlogResultFooter> container.
  • <MTSearchFirst> - The number of the first search result on the current page. This tag should be used with a <MTBlogResultHeader> or <MTBlogResultFooter>container.
  • <MTSearchLast> - The number of the last search result on the current page. This tag should be used with a <MTBlogResultHeader> or <MTBlogResultFooter>container.
  • <MTSearchIfNextPage> - A conditional tag that displays its content if there is a subsequent page of search results. This tag should be used with a <MTBlogResultHeader> or <MTBlogResultFooter>container.
  • <MTSearchNextPageLink> - Output a URL to the next page of search results. This tag should be used within <MTSearchIfNextPage> tags.

As you may have noticed, most of the tags above are identical to the ones used for the existing CGI-based search results. This is by design, so you will easily be able to cut-and-paste your existing search template code into the Fast Search template, though some minor modifications may be required.

Working Examples:

Here are some working examples you can try. Feel free to try additional search queries and note the speed that searches are performed.

  • Mars Rover Blog has over 5,000 entries. Example search: "water on mars". Note that this example shows the default FastSearch template, which is very similar to the default search results template in MT 3.2.
  • Seinfeld Blog has over 8,000 entries, 180 of which consist of the episode descriptions and scripts of all 180 episodes. Fast Search powers the Seinfeld Script Search, which is restricted to a single category containing the episodes. Example search: 'bubble boy'

Requirements:

  • Movable Type 3.2 or 3.3
  • mySQL 4.0.1 or higher

Instructions

  1. Download the plugin and expand the zip file.
  2. Upload the contents of the 'plugins' folder to the 'plugins' directory of your MT installation (usually something like /cgi-bin/mt/plugins).
  3. Upload the contents of the 'php' folder to the 'php' directory (usually something like /cgi-bin/mt/php)
  4. Login to the MT admin interface. If you already logged in, choose 'Main Menu'
  5. If your are running MT 3.3, you should be redirected to an 'Upgrade' screen at this point. The Fast Search upgrade process will update your database to add a fulltext index to the table in your database where entries are stored. Note that this may take some time if you have many entries, and this will add to the overall size of your database.
  6. If you are running MT 3.2, you will not see the upgrade screen (as it is a 3.3 feature), so you need to create the index by browsing to the 'Settings' of a blog where you want to use Fats Search. Choose the 'Plugins' tab then find 'Fast Search' and choose 'Settings'. Now click the link in bold that says "Click here to create or rebuild the FastSearch fulltext index". Again, this may take some time, please be patient. After the index has been created, hit the Back button.
  7. Now browse to the 'Publishing' settings tab for the blog, and scroll down to the Setting called "Dynamic Publishing". If the first option, "Build all templates statically", is selected, you should change this setting to "Set each template's Build Options separately" and click "Save Changes" at the bottom of the screen. Otherwise, you don't need to make any changes here.(Note that change this setting will create an .htaccess file in the root path of the blog. Normally you won't notice this and everything will work fine, but if you have an existing.htacces file, you may want to take a look at it to make sure everything looks okay)
  8. If you just changed your Dynamic Publishing settings in the previous step, you should now rebuild all files for this blog by choosing "Rebuild Site" from the left menu, then "Rebuild all Files". You should also ensure that you have a "Dynamic Site Bootstrapper" (mtview.php) index template and make sure that it gets built, if it hasn't been built previously.
  9. Now return to the Fast Search settings ('Plugins' tab within 'Settings') and check the box to enable Fast Search. You may also want to adjust the settings for Maximum Search Results and logging, then click "Save Changes".
  10. Open the Fast Search settings once again and choose "Click here to install the default Fast Search Template." The template will be created and then displayed. This is an dynamic Index template (which can be customized) used to display the search results. (If desired you can also skip this step and create the index template manually, use the template tags as desired, or by cutting and pasting your exisiting search template code)
The Search Form

If you already have search forms on your blog pages, you need to update them to point to the new Fast Search template. For each template that contains a search form, look for the following (or similar):

<form method="post" action="<$MTCGIPath$><$MTSearchScript$>"

...and change it to:

<form method="post" action="<$MTBlogURL>fastsearch"

...save the template and repeat this step for every template that has a search form.

If you want to insert a new search form on your site, or completely replace existing forms, you can use the following:

<form method="get" action="<$MTBlogURL$>fastsearch">
    <label for="query" accesskey="4">Search this blog:</label><br />
    <input id="query" name="query" size="20" />
    <input type="submit" value="Search" />
</form>

Of course you can also add optional fields to the form such as:

<input type="hidden" name="order" value="date" />

....to sort the results by date, or....

<input type="hidden" name="category" value="5" />

...to restrict the search to category_id = 5.

Once you have the search form(s) on you site, rebuild those pages and start searching. You should notice significant speed and resource improvement, especially on blogs with many entries.

Download Fast Search

Non-commercial use - FREE ( although you must include a

Movable Type search results powered by 
<a href="http://mt-hacks.com/fastsearch.html">Fast Search</a>
link on your search results pages.

Also, donations are appreciated:

Commercial use - $97.00

Download Now

Download Now
Downloads: 4783 (since 3/6/07)

Membership required, please sign-in or register:

As always, suggestions and feedback are appreciated. Please reply to this entry.

Note: FastSearch v1.0 is a suitable replacement for most implementations of the built-in search function in Movable Type. However, there are a few features that Fast Search v1.0 does not include. Fast Search v1.0 does not support comment searches, multi-blog searches (searching multiple blogs at the same time), regexp search, case-senstive search, the use of AND and OR operators, and Edit Entry Links). Also, Fast Search v1.0 does not inlcude MT 3.3 search features such as tag search. Some of these features may be supported in future versions -- please let me know what features you would like to see.

Updated: 8/9/06 07:39:00 - added some additonal info to the instructions based on feedback from Patrick.

Introducing Smart Rebuild, a plugin for Movable Type that speeds up rebuilding. Version 1.0 of this plugin specifically addresses the speed of rebuilding category archives from the MT admin interface.

Do you need this?

  • If category rebuilds are taking a long time, you may want to try Smart Rebuild.

  • If you are getting 500 - Internal Server Errors when rebuilding, you may want to try Smart Rebuild.

  • If you have a blog with a large number of entries and/or a large number of categories (or both), you may want to try Smart Rebuild.

Download Now

SmartRebuild.zip

Membership required, please sign-in or register:

Installation:

1. Expand zip file and upload the "Smart Rebuild" directory to your "plugins" directory within Movable Type (this is often something like /cgi-bin/mt/plugins).

2. Try it by clicking the "rebuild site" button from the left menu and choose "Rebuild All Files" or "Rebuild Category Archives Only".

You may want to time your category rebuilds before installing the plugin, and then again after you install it. This will help give you a sense of the improvement, which will vary depending on your site.

Tested with MT 3.2 and 3.31.

Future versions of Smart Rebuild may contain further rebuild optimizations.