stocksy.co.uk
"the site for those who crave disappointment"

Sponsored Links

Navigation Menus in MovableType

7th Jan 2006, 21:38:26

By James Stocks

The Movable Type 3.2 default templates come with a sidebar on the Main Index Page, but not on any of the other pages. This sidebar has become the main navigation menu on my site, so to follow consistency rules I had to figure out how to get this to appear on the Category Archive, Date-Based Archive and Individual Entry Archive pages. I used PHP includes instead of copying the sidebar into each of the pages. This makes updating the sidebar easier, as it only has to be done in one place. Here's how I did it.

First you need to set Movable Type to produce PHP files (obviously this will only work if the server supports PHP). Go to Settings → Publishing Settings and set the File Extension for Archive Files to 'php'.

You will need to edit the following templates:

To make template editing easier, I copied the code from these templates into a text editor. You will also need to create a new template under Indexes - I called it sidebar.php

Next, cut the sidebar code from the Main Index and paste into sidebar.php. The sidebar code is everything in the <div id="beta"></div> tags. In Main Index, replace with <?php include "/full/webserver/path/to/sidebar.php";?> Be careful to grab the correct closing div tag - there should be 4 left after the PHP include.

To check that everything is OK so far, copy the template code back into the template editor, then click Save and Rebuild.

Now, to put the sidebar into the other templates is just a repeat of the above. If the template does not already contain the sidebar code (<div id="beta"></div>) you will need to carefully figure out the nested divs to get it in the right place. The PHP include goes after the closing <div id="alpha"> and should leave 4 closing div tags after it. You will also need to change the class of the body to <body class="layout-two-column-right">

That should give you your navigation menu on all the archive and article pages.

New Comments

Some Rights Reserved