Help - Search - Members - Calendar
Full Version: Category specific calendars
Movable Type Community Forum > Additional Resources > Tips and Tricks
imperfetto
My blog only has two categories, which are very seperate from each other. Entries are either in the 'Journal' category or the 'Quickies' category.

I have two seperate archive pages for these two categories. And on these archive pages I want to use the MTCalendar to provide a link to entries within the entry's respective category. I DO NOT want to be able to get to one category's entries from the other category's archive page.

However, If I try to specify one calendar to only display the links to one category (either Journal or Quickies, not both) I get empty cells where the other category had entries. And if I specify both categories, but leave one just without links, I get cells with repeated dates because I posted an entry in both categories that day.

Please see the calendars on the side of this page to see what I mean. Notice how some days in the calendar are completely blank? I'm a perfectionist, I know, but there has to be some way to fix this.

I've tried two plug-ins. Catentries and excludecat. Both were unsuccessful.

My code for my calendar is this:

CODE
<MTArchiveList lastn="4" archive_type="Monthly">
<ol><font face=webdings>6</font> <span class="quickietitle"><$MTArchiveDate format="%B %Y"$></span></font></ol>
<table border="0" cellspacing="4" cellpadding="0" summary="Monthly calendar" align="center" width="100%">
<tr class="quickiebody">
<th abbr="Sunday" align="center">Sun</th>
<th abbr="Monday" align="center">Mon</th>
<th abbr="Tuesday" align="center">Tue</th>
<th abbr="Wednesday" align="center">Wed</th>
<th abbr="Thursday" align="center">Thu</th>
<th abbr="Friday" align="center">Fri</th>
<th abbr="Saturday" align="center">Sat</th>
</tr><MTCalendar month="this">
<MTCalendarWeekHeader>
<tr class="quickiebody"></MTCalendarWeekHeader>
<td align="center" class="quickiebody">
<MTCalendarIfEntries>
<MTEntries lastn="1" category="Journal">
<a href="<$MTEntryLink$>" title="<MTEntryTitle>"><$MTCalendarDay$></a>
</MTEntries>
</MTCalendarIfEntries>
<MTCalendarIfNoEntries><$MTCalendarDay$></MTCalendarIfNoEntries><MTCalendarIfToday><font color="#FFFFFF"><MTCalendarDay></font></MTCalendarIfToday><MTCalendarIfBlank> </MTCalendarIfBlank></td>
<MTCalendarWeekFooter></tr></MTCalendarWeekFooter>
</MTCalendar>
</table>
</MTArchiveList>


Thanks for help. smile.gif I just know I've overlooked something here.
imperfetto
It's been a few days. Does this mean there's no hope for me? smile.gif
girlie
I think the calendar tags ignore category context unless you specifically provide the category like this:

CODE
MTCalendar category="Journal">


and you really can't do that in a Category Archive because it would require nesting of tags (i.e., category="", which isn't possible.)

So I turned to the Tag Invoke plugin to overcome that obstacle. After installing it, I was able to get a calendar for the most recent month which only showed entries in that archive's categories:

CODE
<MTTagInvoke tag_name="MTCalendar">
<MTTagAttribute name="category"><MTArchiveTitle></MTTagAttribute>
<MTTagContent>
<MTCalendarWeekHeader><tr></MTCalendarWeekHeader>

<td align="center"><span class="calendar">
<MTCalendarIfEntries>
<MTEntries lastn="1"><a href="<$MTEntryPermalink$>"><$MTCalendarDay$></a></MTEntries>
</MTCalendarIfEntries>
<MTCalendarIfNoEntries><$MTCalendarDay$></MTCalendarIfNoEntries>
<MTCalendarIfBlank> </MTCalendarIfBlank></span></td>
<MTCalendarWeekFooter></tr></MTCalendarWeekFooter>
</MTTagContent>
</MTTagInvoke>


The problems came in when I tried to get more than one month's calendar. Wrapping the calendar code inside of the MTArchiveList tags throws the MTArchiveTitle tag into a month context instead of a category context, giving an error about "no such category 'March 2004'", and thus losing the surrounding Category Archive context.

So my next best suggestion would be using PHP or SSI if it's available to you. You can create two index templates, one for each of the categories, and write the code like this:

CODE
<MTArchiveList lastn="4" archive_type="Monthly">
<ol><font face=webdings>6</font> <span class="quickietitle"><$MTArchiveDate format="%B %Y"$></span></font></ol>
<table border="0" cellspacing="4" cellpadding="0" summary="Monthly calendar" align="center" width="100%">
<tr class="quickiebody">
<th abbr="Sunday" align="center">Sun</th>
<th abbr="Monday" align="center">Mon</th>
<th abbr="Tuesday" align="center">Tue</th>
<th abbr="Wednesday" align="center">Wed</th>
<th abbr="Thursday" align="center">Thu</th>
<th abbr="Friday" align="center">Fri</th>
<th abbr="Saturday" align="center">Sat</th>
</tr>
<!--change category here for each template-->
<MTCalendar month="this" category="Journal">
<MTCalendarWeekHeader>
<tr class="quickiebody"></MTCalendarWeekHeader>
<td align="center" class="quickiebody">
<MTCalendarIfEntries>
<MTEntries lastn="1">
<a href="<$MTEntryLink$>" title="<MTEntryTitle>"><$MTCalendarDay$></a>
</MTEntries>
</MTCalendarIfEntries>
<MTCalendarIfNoEntries><$MTCalendarDay$></MTCalendarIfNoEntries>
<MTCalendarIfToday><font color="#FFFFFF"><MTCalendarDay></font></MTCalendarIfToday>
<MTCalendarIfBlank> </MTCalendarIfBlank></td>
<MTCalendarWeekFooter></tr></MTCalendarWeekFooter>
</MTCalendar>
</table>
</MTArchiveList>


Set the output file path to journal.inc and quickies.inc, respectively, then include the correct file in your category archives like this:

CODE
<?
include ('/home/you/public_html/blog/<MTArchiveCategory dirify="1".inc');
?>
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.