« New Photo Gallery - Fall Leaves at Night | SEO Tools (Search Engine Optimization) »

Customized Search Template in MovableType 3.x

MovableType has added numerous improvements since I started using it with v.2.2x. One of the sucky features are the search pages and templates that generate results, they're CGI and not as easy to customize as the rest of the shell.

But, turns out you can still do it...


1. Go to the search_templates directory and make a copy of default.tmpl, then rename it. I have two separate domains on my server, so I call them search_domain1.tmpl and search_domain2.tmpl. Don't worry, no one will ever see the names, so get creative...!

2. Open up mt-config.cgi and add the following line:

AltTemplate japan-page search-domain1.tmpl

Where japan-page is the template name and search-domain1.tmpl is the actual template file name we created in step 1.

Before:

-snip-
##################### REQUIRED SETTINGS ########################

CGIPath http://www.japan-page.net/blog/
StaticWebPath http://www.japan-page.net/blog/mt-static/

#================ DATABASE SETTINGS ==================
-snip-

After::

-snip-
##################### REQUIRED SETTINGS ########################

CGIPath http://www.japan-page.net/blog/
StaticWebPath http://www.japan-page.net/blog/mt-static/
AltTemplate japan-page search-domain1.tmpl

#================ DATABASE SETTINGS ==================
-snip-


3. Edit the new tmpl file to your hearts content.




4. Test the template file before you put it in production. You can call the template file on the following URL before you make the cutover.

http://www.yourdomain.com/path/to/mt-search.cgi?Template=Name , where Name is the name you assigned in step 2.


5. When you're ready to put the new template in production, edit your index files and add the following:

<input type="hidden" name="Template" value="NAME" /> where, once again, NAME is the name you assigned in step 2.

In my blog the search box is part of a sidebar module, but regardless the code is the same:

<form method="get" action="<$MTCGIPath$><$MTSearchScript$>">
<input type="hidden" name="IncludeBlogs" value="<$MTBlogID$>" />
<label for="search" accesskey="4">Search this blog:</label><br />
<input id="search" name="search" size="20" />
<input type="hidden" name="Template" value="japan-page" />
<input type="submit" value="Search" />
</form>


See the MovableType 3.2 User Manual here. (Less details, this article is better for kinda sorta still MT noobs like me).

Post a comment

(If you haven't left a comment here before, you may need to be approved by the site owner before your comment will appear. Until then, it won't appear on the entry. Thanks for waiting.)