Stupid Manila Tricks: List recent posts on News Items page

There are probably only a few people in the world who would care about this anymore, but today I got sick of having to browse through my calendar to find links to past posts that I wanted to link to from new ones.

So I added a macro to my template that lists the last 35 posts underneath my pending news items list. Here’s the snippet:

In your site’s Template (not Home Page Template), right after the {bodytext} macro, add

{if method=="GET" and (path=="/newsItems/" or path=="/newsItems/default") {"<h2>Recently Posted</h2>" + viewNewsItems (35, newsItemTemplate:"<a href='{permaLinkUrl}'>{title}</a><br />")} else {""}}

Note: You’ll have to first make both {path} and {method} legal with no parameters via your server’s Legal Macros settings page for this to work properly.

What it does is add a list of links to the 35 most recent news items (a.k.a. blog posts) underneath the pending news items, but only on that page, and only on a GET (not a POST). Of course you can change 35 to some other value if you want to.

See also: Docs for the viewNewsItems Macro

I also used the {viewNewsItems ()} macro to make a page listing all posts on this site.

Be First to Comment

Post a comment