Learning Movable Type: Keeping an Entry at the Top

Sometimes you may want to keep an entry, or all entries within a certain category, at the top of your weblog, above all of your other entries. For example, you may want to highlight announcements at the top of your site, or you might have a site explanation or introduction that you wish to maintain at the top. There are several ways to accomplish this.

1. Changing the date of the entry.

authored_on.gifIf all you want to do is to put one particular entry at the top of your blog, perhaps only for a limited time, the easiest way to accomplish this is to give it a date that is posted at a later date than all of the other entries. To do this, in the edit entry window, scroll to the bottom of the page. On the left is an "Authored on" area. Enter a date more recent than, or in the future of, all of your other entries. The problem with this is that if you choose a date far out in the future, and you display prominently the date posted, it will look a little weird to anyone reading it.

2. Hard-coding your entry into the Main Index Template

If the content you want at the top of your page doesn't change, the most practical thing to do is to put the text in the Main Index or archive template where you want the content to appear. In MT3, put the content between the div ID alpha-inner and the MTEntries tag like so:

<div id="alpha">
<div id="alpha-inner" class="pkg">

Your text would go here:


3. Use the Entry plugin.

You can specify an entry in your template layout by the ID of the entry using David Rayne's Entry plugin.

<MTEntry id="118">
<$MTEntryTitle$><br />

Place the MTEntry code, with the entry ID you have specified, above your existing MTEntries tag in your Main Index template. You can find the entry ID by looking at the browser URL window while editing that entry.

4. Place the entries of only one category at the top

If you want only the entries of a certain category to stay at the top of your blog, for example an "announcements" category, you can do that easily by adding the following code to your Main Index template before the existing MTEntries tag:

<MTEntries lastn="1" category="Announcements">

This method will put the latest entry from your specified category in the top spot.

If you follow this method, you may also want to exclude entries from the specified category in your general list of entries. To do this, use the ExcludeCategories plugin. With this plugin installed, all you need to do to exclude a category is to change your <MTEntries> and </MTEntries> tags of your main body of entries in your Main Index template to <MTEntriesExCat category="Put_the_name_of_category_here">, and its complementary closing tag.

You may also want to style this section differently, by placing a border and a different background color around the latest announcement. To do this, add a new class on your stylesheet. For example:

.announcement {
padding: 10px 10px 10px 10px;
background-color: #effbdb;
border: solid 1px #7c9e40;

On your Main Index template add the new div class, nesting the top entry section between the opening and closing div tags of the new class. In this example, the div class tag is <div class="announcement">.

5. Use the MultiBlog plugin

You can use David Rayne's MultiBlog plugin to pull in entries from other blogs to take a preeminent position on your weblog. (See Combining Multiple Blogs into One tutorial.)

Posted by Elise Bauer on September 11, 2004 4:43 PM to Learning Movable Type http://www.learningmovabletype.com/