default userpic

Calendar "previous month" and "next month" arrows?

Vote 0 Votes

Newbie here. Can someone point me to instructions on how I can add “previous month” and “next month” navigation arrows to the Calendar widget?

Thanks in advance for any help!

Reported on Movable Type 4.2

13 Replies

| Add a Reply
  • This might work

        <mt:ArchiveNext type="Monthly">
          <a href="<$mt:ArchiveLink$>"
            title="<$mt:ArchiveTitle escape="html"$>">Next</a>
        <mt:Else>
           <!-- output when no next archive is available -->
        </mt:ArchiveNext>
    
  • No dice. Here's the error I get when I try to publish the site:

    An error occurred publishing category '3':
    Publish error in template 'Category Entry Listing':
    Error in tag: error in module Sidebar:
    Publish error in template 'Sidebar':
    Error in tag: Error in tag:
    Error in tag:
    error in widget Calendar:
    Publish error in template 'Calendar':
    Error in tag:
    Error in tag:
    You used an MTarchiveprevious tag without a date context set up.

    Any thoughts?

  • Can you post your code for the calendar widget template.

  • <mt:IfArchiveTypeEnabled archive_type="Individual">
    <div class="widget-calendar widget">
    
    


    <h3 class="widget-header">


    <mt:ArchivePrevious type="Monthly">
    <a href="<$mt:ArchiveLink$>"
    title="<$mt:ArchiveTitle escape="html"$>">&laquo;</a>
    <mt:Else>
    <!-- output when no previous archive is available -->
    </mt:ArchivePrevious>


    <$mt:Date format="%B %Y"$>


    <mt:ArchiveNext type="Monthly">
    <a href="<$mt:ArchiveLink$>"
    title="<$mt:ArchiveTitle escape="html"$>">&raquo;</a>
    <mt:Else>
    <!-- output when no next archive is available -->
    </mt:ArchiveNext>


    </h3>

    <div class="widget-content">
    <table summary="Monthly calendar with links to daily posts">
    <tr>
    <th abbr="Sunday">Sun</th>
    <th abbr="Monday">Mon</th>
    <th abbr="Tuesday">Tue</th>
    <th abbr="Wednesday">Wed</th>
    <th abbr="Thursday">Thu</th>
    <th abbr="Friday">Fri</th>
    <th abbr="Saturday">Sat</th>
    </tr>
    <mt:Calendar>
    <mt:CalendarWeekHeader>
    <tr>
    </mt:CalendarWeekHeader>
    <td>
    <mt:CalendarIfEntries>
    <mt:Entries lastn="1">
    <a href="<$mt:EntryPermalink$>"><$mt:CalendarDay$></a>
    </mt:Entries>
    </mt:CalendarIfEntries>
    <mt:CalendarIfNoEntries>
    <$mt:CalendarDay$>
    </mt:CalendarIfNoEntries>
    <mt:CalendarIfBlank>&nbsp;</mt:CalendarIfBlank>
    </td>
    <mt:CalendarWeekFooter>
    </tr>
    </mt:CalendarWeekFooter>
    </mt:Calendar>
    </table>
    </div>
    </div>
    </mt:IfArchiveTypeEnabled>

  • Try moving the next | previous code so that it is within the <mt:Calendar> tag block.

  • Nope, same error. I put the blocks just inside the end of the mt:Calendar block.

  • FogBugs case 91780 added (feature request submitted). Thank you for your help.

  • default userpic

    hey folks!

    I just started using MT, and I am going through the same thing trying to create an archive calendar.

    This post was very helpful. but I'm now getting an error.

    Publish error in template 'Main Index': Error in tag: error in module CalendarArchive: Error in tag: You used an MTarchiveprevious tag without a date context set up.

    I'm posting the whole code for anyone who is interested:

    <!--module: CalendarArchive-->
    <h2> Archives </h2>
    <div class="module-calendar module">
    <h3 class="module-header">
    <caption style="text-align:left;">
    <mt:ArchivePrevious archive_type="Monthly"><a href="<$mt:ArchiveLink$>" title="<$mt:Date format="%B"$>">&laquo;</a> &nbsp; </mt:ArchivePrevious>
    <a href="<$MTBlogArchiveURL$><$mt:Date format="%Y/%m/"$>"><$mt:Date format="%B %Y"$></a>
    <mt:ArchiveNext archive_type="Monthly"> &nbsp; <a href="<$mt:ArchiveLink$>" title="<$mt:Date format="%B"$>">&raquo;</a></mt:ArchiveNext>
    </caption>
    </h3>
    <div class="module-content">
    <table summary="Monthly calendar with links to each day's posts">
    <tr>
    <th abbr="Sunday">Sun</th>
    <th abbr="Monday">Mon</th>
    <th abbr="Tuesday">Tue</th>
    <th abbr="Wednesday">Wed</th>
    <th abbr="Thursday">Thu</th>
    <th abbr="Friday">Fri</th>
    <th abbr="Saturday">Sat</th>
    </tr>
    <MTCalendar>
    <MTCalendarWeekHeader>
    <tr>
    </MTCalendarWeekHeader>
    <td>
    <MTCalendarIfEntries>
    <MTEntries lastn="1">
    <a href="<$MTEntryPermalink$>"><$MTCalendarDay$></a>
    </MTEntries>
    </MTCalendarIfEntries>
    <MTCalendarIfNoEntries>
    <$MTCalendarDay$>
    </MTCalendarIfNoEntries>
    <MTCalendarIfBlank>&nbsp;</MTCalendarIfBlank>
    </td>
    <MTCalendarWeekFooter>
    </tr>
    </MTCalendarWeekFooter>
    </MTCalendar>
    </table>
    </div>
    </div>

    <!--/module: CalendarArchive-->

    apologies for the look of the code. for some reason the "pre" tags aren't working?

    any tips would be appreciated.

    and ya, why aren't the previous/next links part of the regular code?

    and one off the cuff question for a MT beginner: What's the difference between a Module and a Widget?

    Thanks!

  • i'm pretty sure that was the same error i got. but so that other people can help us out, you may want to use the special form to attach your code so that the code itself is legible.

    as far as your question, "and one off the cuff question for a MT beginner: What's the difference between a Module and a Widget?", please don't threadjack, or else this thread will get off the topic. please post that in a new thread. thanks.

  • I really need the same. The archive_type modifier does not work as expected. It should always display a next or previous month if there is one and not throw a 'not in date context' error if it's a main index or individual post.

    On top of that, the manual states that type and archive_type are the same modifiers. But they have different results. type produces an out of date context error on individual entries, not on main indexes, archive_type vice versa. In both cases a link to next/previous month should be given, since you specifically request for a monthly context.

    This makes the calender function severely limited imo

  • I've found the solution:

    <mt:If name="datebased_archive">
    <div id="next-prev">
    <div id="prev"><mt:ArchivePrevious archive_type="Monthly"><a href="<$mt:ArchiveLink$>"><$mt:ArchiveTitle$> »</a></mt:ArchivePrevious></div>
    <div id="next"><mt:archivenext archive_type="Monthly"><a href="<$mt:ArchiveLink$>">« <$mt:ArchiveTitle$></a></mt:ArchiveNext></div>
    </div>
    <mt:else>
    <mt:archivelist archive_type="Monthly" lastn="1">
    <div id="next-prev">
    <div id="prev"><mt:ArchivePrevious archive_type="Monthly"><a href="<$mt:ArchiveLink$>"><$mt:ArchiveTitle$> »</a></mt:ArchivePrevious></div>
    <div id="next"><mt:archivenext archive_type="Monthly"><a href="<$mt:ArchiveLink$>">« <$mt:ArchiveTitle$></a></mt:ArchiveNext></div>
    </div></mt:archivelist>
    </mt:else>
    </mt:if>

    Works perfectly

  • Hm, works perfectly instead within the context of an individual entry. Once you click on an individual entry, the next month/previous month will result in only the previous month being linked to the previous month of the current date (in reality). It does not generate a next/prev month in respect to the date of the entry.

    No way to create an archive-context in this example right?

Add a Reply

If you need to share template code, replace all the "<" signs with "&lt;" or use this utility.

Forum Groups

1773 6162

Last Topic: Excluding categories from blog by kholechek on Feb 9, 2012

86 302

Last Topic: website entries by masoud on Oct 26, 2011

1429 5077

Last Topic: What apocalypse hit this community in the middle of 2011? by 75th on Feb 10, 2012

695 2910

Last Topic: Insert Image / File Fails by Russ Miller on Feb 10, 2012

84 291

Last Topic: How to have some other characters in entry basename automatically written by Afshin Haghighatnia on Dec 22, 2011

173 737

Last Topic: About the MT version stated in HTML source by Alex E. Schneider on Feb 7, 2012

190 567

Last Topic: Analytics Reporting by michael webster on Feb 5, 2012

48 210

Last Topic: An idea and also a request by Afshin Haghighatnia on Jun 29, 2011

64 246

Last Topic: jQuery in MT 5.1 still at 1.4 - why? by perlmonkey on May 25, 2011

code.sixapart.com

137 478

Last Topic: Getting a thumbnail with xpath by Peter on Mar 13, 2011

222 720

Last Topic: Custom Field for Asset Not Appearing by android on Feb 9, 2012