Learning Movable Type: Pull Down Menus

To save space on your sidebar listing of categories or monthly archives, you might want to use a pull-down menu like so:

To do this for your category list, make sure that you have category archiving selected as an archiving option in your weblog config, and add the following code to your sidebar:

<form action="" name="pulldown1">
<select name="mypulldown1"
<option value="">Select Category</option>
<MTArchiveList archive_type="Category">
<option value="<$MTArchiveLink$>"><$MTArchiveTitle$></option>

You can also create a pulldown menu for your monthly archives using the following code:

<form action="" name="pulldown2">
<select name="mypulldown2"
<option value="">Select Month</option>
<MTArchiveList archive_type="Monthly">
<option value="<$MTArchiveLink$>"><$MTArchiveDate format="%B %Y"$></option>

Note you can use a different MT date format in place of the one given. Also, you can create a new form name and select name; just swap out the new names on the OnChange line.

Please note that I'm not an expert on how Javascript forms work. I find examples on the MT Forums and on individual blogs and experiment with them until they work for me. These two code examples I've listed I've tried on one of my test blogs and they appear to work fine. They even validate.

Links: Expandable List Menus - a way of showing a list of entries by category, used in LMT in the Table of Contents. Hierarchical Dropdown List of Category Archives - David Raynes' drop down menus that show the category hierarchy if you use subcategories. Brad Choate's PHP solution for Pull Down Menus that preserve subcategory hierarchy

Posted by Elise Bauer on November 22, 2004 10:38 PM to Learning Movable Type http://www.learningmovabletype.com/