Help - Search - Members - Calendar
Full Version: Link Previous Month's Archive Page
Movable Type Community Forum > Additional Resources > Tips and Tricks
JoshuaKaufman
I'd like to include a link to the previous month's archive page from every page on my weblog.  For example, this month is February so I'd like to include a link to the January monthly archive.  What the best way to do this?  Thank you.
nammer
Joshua -

This is the "standard" relative navigational MT code; placing this in your date-based archive tempate will ensure that each month has a link to the next and previous months, as well as a link to the main index:

CODE
<MTArchivePrevious>
<a href="<$MTArchiveLink$>">« <$MTArchiveTitle$></a> |
</MTArchivePrevious>
<a href="<$MTBlogURL$>">Main</a>
<MTArchiveNext>
| <a href="<$MTArchiveLink$>"><$MTArchiveTitle$> »</a>
</MTArchiveNext>


Does that help?  By the way, I like your "I heart MT button" - that's clever!

Donna
JoshuaKaufman
I know that's the standard code, but I need a link I can place on every page, including some template modules, and that won't work in some of those templates.  For example, if I use that code on the Main Index, MT says that I can't use those tags with a date context.

P.S. Thanks for the compliment on my MT button smile.gif
girlie
Well, where on your Main Index are you wanting a link to the previous month? Because I see a mix of entries on your main page from different months - so I'm trying to figure out the context in which you want to place it.
JoshuaKaufman
This isn't for my page, it's for Boxes and Arrows.  That "Previously" tab needs to always point to the last month's archive.
JoshuaKaufman
Maybe I should add that I'm not doing this just for fun.  I'm actually on the Boxes and Arrows team.

Maybe PHP has the answer.  Is there way to create a URL with PHP that looks like this:
2002_99.php (where 99 is always the previous month in double digit format)

Thank you.
bmk
Something like this?  (I'm not exactly sure still what you're looking for smile.gif)
CODE
<?
$last_month = mktime(0,0,0,(date("m")-1),date("d"),date("Y"));
$last =  strftime ("%Y_%m", $last_month);
echo $last;
?>
bmk
Did this work?  :)
JoshuaKaufman
Brenna, you make it look too easy!  It did work! smile.gif Thanks!
bmk
Cool, I was wondering about it.   I wasn't sure if that's what you meant and it's nifty.  :D
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-2009 Invision Power Services, Inc.