March 12, 2004

Previous Entries and Lastn

The default main index page of a Movable Type weblog displays entries made in the last 7 days. You can change this number by entering a different number in the weblog config preferences.

lastn
If you keep the default setup, you may notice that if you don't post for a while (more than 7 days) your main weblog index page becomes blank - no entries. To change the setup so that the weblog displays the last 7 entries instead of entries in the last 7 days you need to add a lastn attribute to the MTEntries tag.

Changing <MTEntries> to <MTEntries lastn="7"> in the Main Index template will cause the index page to display the last 7 entries. Adding the attribute lastn="10" will cause the index page to display the last 10 entries, and so forth.

Previous Entries
Sometimes it is useful to show a list of the most recent entries that came before the entries that are displayed on your main index page. Scroll to the bottom of Learning Movable Type to see an example. Rather than creating a super long page with 17 entries, you might want to display 7 entries and show a list of the 10 entries that came before, with links to their corresponding full entries.

To show a list of previous entries you need to employ the "offset" attribute. For example, if you wanted to show a list of the 10 entries that came before your 7 most recent entries, you would use a tag that looked like this:

<MTEntries lastn="10" offset="7">

The code that I use here in Learning Movable Type looks something like this:

<h3>Previous 10 entries...</h3>
<MTEntries lastn="10" offset="7">
<a href="<$MTEntryPermalink$>"><$MTEntryTitle$></a> <$MTEntryDate format="%b %e, %Y"$><br />
</MTEntries>

This code I've placed right after the </MTEntries> tag that is the closing tag for the MTEntries section of code that governs the main display of entries on the page.


Has this tutorial been helpful? Please consider linking to Learning Movable Type at http://learningmovabletype.com/ . Thanks!

Posted by Elise Bauer on March 12, 2004 to General Tips and Tricks
Comments(7) | Email to a friend | Printer-friendly version


Trackback

If you would like to send a trackback
please use the following URL: http://learningmovabletype.com/cgi-bin/mt32/mt-tb.cgi/192

Comments

I had lastn=5 but in my config prefs I had 7 days set, and entries still disappeared after 7 days.

What should I set my config prefs to be if I always want to show the 5 most recent entries?

Currently I have 9999, but this seems dumb.

Wayne - the config settings in this case shouldn't make any difference. Did you remember to save and rebuild your template?

Elise - yes I did rebuild... its the activity of rebuilding that makes MT decide it is time to remove all the entries because of the config setting.

lastn was definitely 7... template was saved.

Wayne, from your first post, did you have lastn=5 or lastn="5" ?

Also, I'm not the best person to troubleshoot this. The directions I'm giving are straight out of the Movable Type manual. If you are still having trouble, I would suggest going to the Movable Type Support Forums where there are many people with indepth knowledge of all the different problems that could be occuring for various reasons - browser bugs, html errors, etc. The forums can be found at http://www.movabletype.org/support/. Good luck!

Elise you did it!

I didn't have the number quoted... oh dear.

What a strange beast.

lastn="5" did the trick.

what if you do want it to show the days? mine is set to show the last 7 entries but I want it to show the last 7 days.

elenamary - don't use lastn. Go to your "weblog config" window and select the "preferences" section. In Preferences, select the Number of Days Displayed you want.

Comments are now closed for this entry.


Email to a friend

Email this article to:


Your email address:


Message (optional):