Help - Search - Members - Calendar
Full Version: how to list posts by month on index?
Movable Type Community Forum > Additional Resources > Tips and Tricks
chutney
I'm trying to use MT to put my work's newsletter into a database-driven website. I've figured out how to get the date heading to read by the month and year, but it still want to group the posts themselves by day.

The effect is that there are as many "May 2003" headings are there are daily posts for that month. What's the trick?
girlie
I think you want <MTDateHeader>:

QUOTE
MTDateHeader
A container tag: the contents of this container will be displayed only if this entry marks a new day in the list of entries. As such this is really only useful inside an MTEntries container. For example:
CODE
<MTEntries>
 <MTDateHeader>
   <$MTEntryDate format="%B %e, %Y"$>
 </MTDateHeader>
 Title: <$MTEntryTitle$>
</MTEntries>
chutney
I've got the date format displaying correctly. It's the sorting of the posts that's not right. This is what I've got now:
CODE
<MTEntries>
<$MTEntryTrackbackData$>

    <MTDateHeader>
    <h2 class="date">
    <$MTEntryDate format="%B %Y"$>
    </h2>
    </MTDateHeader>

So if there's a post on May 1 and May 3, it displays:

May 2003
Post from first day of May yada yada.

May 2003
Post from third day of May, but listed with it's own month heading.
kadyellebee
So how would you like it to display?

QUOTE
May 1, 2003
Post from the first day...

May 3, 2003
Post from the third day....


if so, the date format that Maddy posted should work...

Kristine
maddy
I didn't post any code (yet)! tongue.gif

You'll really need to give an example of how you do want to have your entries laid out.

But, depending on what you want to do, you might like to check out the DateHeaders plugin, in particular the MTMonthHeader option.

If you want to create a list of your entries separated by month, you might also want to look at some code like this:
CODE
<MTArchiveList archive_type="Monthly">
<b><MTArchiveDate format="%B %Y"></b><br />
<MTEntries>
 <MTDateHeader>
   <i><$MTEntryDate format="%B %e"$></i><br />
 </MTDateHeader>
 <$MTEntryTitle$><br />
</MTEntries>
</MTArchiveList>


That will give you something like:

May 2003
May 23
Title One
Title Two
May 12
Title One
Title Two

April 2003
April 26
Title One
April 12
Title One
Title Two

and so on, for all of your entries. If you want to limit display to say, two months, you can change the first line of code like this:
CODE
<MTArchiveList archive_type="Monthly" lastn="2">
kadyellebee
LOL, I saw Girlie's post and then by the time I replied, I typed your name. :giggle: I'm a goof!
Grundy
I am having such trouble with my DateHeaders Plugin - this thread is the closest to an answer that I've come, so I thought I'd bump it up to ask for help (rather than start a new one).

I want to sort my individual archives by year/month, without actually enabling monthly archives. Like this:

QUOTE
June 2003
-title
-title
-title
May 2003
-title
-title
-title



The closest I'm getting is this:

QUOTE
January 2003
» myopia

January 2003
» Snow!

December 2002
» soap.

December 2002
» wasp woman's revenge

November 2002
» BtVS - Never Leave Me

November 2002
» Timber!


Where each entry is prefixed by its date, rather than a group of entries per date. My code looks like this:

CODE
<MTArchiveList><MTMonthHeader>
<MTArchiveDate format="%B %Y"><br />
</MTMonthHeader><MTDateHeader>
»  <a href="<$MTArchiveLink$>">
<$MTArchiveTitle$></a><br />
</MTDateHeader></MTEntries><br />
</MTArchiveList>


And I just cannot find enough documentation on this plugin to make sense of it. It's a bit frustrating, 'cause I've gotten other things sorted huh.gif Any suggestions would be *seriously* appreciated!

Brooke smile.gif
kadyellebee
I think that your problem is being caused from not actually having monthly archiving turned on. You may need to look at one of the plugins that trick MT smile.gif ArchiveAnyway pops out in my mind as one to try.

Kristine
Grundy
Much thanks, Kristine! Somehow I was thinking that the DateHeaders plugin did trick MT, but obviously... tongue.gif

I'll give ArchiveAnyway a try then - I've got it bookmarked I think, so it looks like I might've tinkered w/ it before. smile.gif
Grundy
Sorted!

This one ended up using both plugins - there may be a way around it. Probably you could sub the DateHeaders plugin for one of the MTCalendar tags, but I'm not terribly familiar with those so... My code looks like this (just in case anyone else needs to do this):

CODE
<MTArchiveAnyway archive_type="Monthly">
<MTMonthHeader>
<MTArchiveDate format="%B %Y"><br />
</MTMonthHeader>
<MTEntries sort_order="descend">
<a href="<$MTEntryLink$>"><$MTEntryTitle$></a><br />
 </MTEntries>
</MTArchiveAnyway>


It was terribly simple once I started working with ArchiveAnyway. I've spent months toying with this off-and-on, and once I did this it all fell into place.

Thank you Kristine! biggrin.gif
kartav
Thanks to new features of MT4.x, now this task is solving without any plugins and the 3d party tricks:
CODE
<MTEntries sort_order="descend">
<mt:SetVarBlock name="this_month"><MTEntryDate format="%Y-%m"></mt:SetVarBlock>
<mt:if name="this_month" ne="$prev_month">
<p><strong><MTGetVar name="this_month"></strong></p>
<mt:SetVarBlock name="prev_month"><MTGetVar name="this_month"></mt:SetVarBlock>
</mt:if>
<p><a href="<MTEntryLink>"><MTEntryTitle></a></p>
</MTEntries>
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Invision Power Board © 2001-2008 Invision Power Services, Inc.