Displaying Entries Not in a Category in Movable Type

| No Comments | No TrackBacks |
It is quite simple to list all (or some) entries in one or more categories using Movable Type's MTEntries tag in combination with the 'category' or 'categories' attribute.  But what if you need to display just the entries that are *not* in a category? I was recently faced with this problem, and here is the solution I came up with:
<mt:setvarblock name="nocategories"><mt:categories glue=" AND ">NOT <mt:categorylabel></mt:categories></mt:setvarblock>
<mt:entries categories="$nocategories">
<li><mt:entrytitle></li>
</mt:entries>

Basically, this snippet of code generates a list of all categories in your blog, each one preceded by 'NOT' and joined together by 'AND'.  So this results in something like "NOT Sports AND NOT Current Affairs AND NOT Humor AND NOT News".  This list is then used in the 'categories' attribute of an MTEntries tag, resulting in a listing of all entries that are not in any of the mentioned categories.  Perfect!

No TrackBacks

TrackBack URL: http://www.movabletips.com/cgi-bin/mt/mt-tb.cgi/1982

Leave a comment


Movable Type Help?

"Can my Movable Type issue or project be taken care of by a professional?" Yes It Can Be! Contact YesItCan.be
Powered by Movable Type 5.2.7