Help - Search - Members - Calendar
Full Version: multi-category specific calendars
Movable Type Community Forum > Additional Resources > Tips and Tricks
mutedgirl
I previously posted part of this question in the thread about MTArchiveYear. But after reading it again, it doesn't make complete sense to me, heh. Also, I'm not sure now that MTArchiveYear is what I'm looking for in order to do what I'd like.

What I want to do is this: I have my entries set up so that they have 2 categories- 1 for the photo I include, and 1 for the text. So it appears like I have a separate entry for each, but it's really one (this way, I can display everything at once, or just one part, etc.) I would like the 'text' part of the archives to appear as a calendar listing, and the 'photo' part is by category. The photo part works great- I used this code to get that done:

CODE
<MTArchiveList archive_type="Category">
<MTFilterCategories include="photo categories here">

<a href="<$MTArchiveLink archive_type="Category">" onMouseover="window.status='view photos in this category'; return true" onMouseout="window.status=''; return true" title="view photos in this category"><$MTCategoryLabel$></a><br>
<$MTCategoryCount$> photos<br><br>
<MTEntries lastn="1">
<div class="thumbs"><a href="<$MTArchiveLink archive_type="Category">" onMouseover="window.status='view photos in this category'; return true" onMouseout="window.status=''; return true" title="view photos in this category"><$MTEntryExcerpt$></a></div>
</MTEntries>

</MTFilterCategories>
</MTArchiveList>


So, I had previously used the ArchiveYear plugin to create yearly calendar archives for the entire site, regardless of category affiliation. But now I have a somewhat complicated issue...

If the entry has no entrybody (which means it has no text entry, just a photo) it doesn't display a link in the calendars. That works great:

CODE
<MTCalendarIfEntries>
<MTEntries lastn="1">
<MTIfNotEmpty var="EntryBody">
<a href="<$MTEntryLink archive_type="Daily"$>" onMouseover="window.status='read entries for this day'; return true" onMouseout="window.status=''; return true" title="read entries for this day"><$MTCalendarDay$></A>
</MTIfNotEmpty>
<MTIfEmpty var="EntryBody">
<$MTCalendarDay$>
</MTIfEmpty>
</MTEntries>
</MTCalendarIfEntries>


But that only tells MT to not show a link and just show the numbers. It's still showing calendars for months with entries with no entry body. I wasn't sure how to get rid of that. Here's the page I'm working with:

http://www.muted.com/history/

So January through August should really just not be showing anything. The links aren't there, which is good. But I'd rather not show those empty months and just have September 2003 - January 2004.

So I guess my question is: is it possible to do this with MTArchiveYear? I don't think there is...because the tag doesn't work like MTArchiveList where you can specify an archive_type. So is there a way to do this using just a regular MTCalendar setup specific to the secondary categories? Maybe using MTArchiveList and MTFilterCategories like I did for the photo setup? I've played around with some different things, but haven't gotten anywhere. I can't get rid of the empty months.

Thanks for reading this far smile.gif And thanks in advance for any help you can give me!
staggernation
I think you could accomplish this with some help from the SetVarBlock plugin. The idea would be to do something like this (untested):
CODE
<MTArchiveYear>
<MTSetVarBlock name="monthentries"><MTCalendar month="this"><MTEntries category="non-photo categories here">1</MTEntries></MTCalendar></MTSetVarBlock>
<MTIfNotEmpty var="monthentries">
...go ahead and display this month
</MTIfNotEmpty>
</MTArchiveYear>

So basically, if there are entries in those categories for the month, the variable will end up being something like "11111," and if there are no entries , it will be empty. Make sure there's no space between the tags within the MTSetVarBlock container.

Of course, this requires looping through the calendar and entries twice (once to test whether there are entries and once to actually display them), so it's not too efficient, but what are you gonna do.
staggernation
Or, since the entry body has no text for photo entries, you could do it like this:
CODE
<MTSetVarBlock name="monthentries"><MTCalendar month="this"><MTEntries><MTIfNotEmpty var="EntryBody">1</MTIfNotEmpty></MTEntries></MTCalendar></MTSetVarBlock>

...if you don't want to specify the categories.
mutedgirl
I tried to download the MTSetVar plugin, but I got a 404 error when I clicked on the link to download the zip file. Does anyone have a copy of this file they can share? So I can give your suggestion a shot! smile.gif Thanks!
digory
I needed this today and found this topic while searching.

A little URL chopping found the plugin here.
mutedgirl
Alright, I downloaded the plugin and started messing with it...but I'm not really getting anywhere. Here's the complete code I have- I use the MTGrid plugin to make tables, so it gets a bit confusing!

CODE
<table align="center" border="0" cellpadding="12" cellspacing="0">

<MTGrid num_columns="4">

<MTArchiveYear order="descend">

<MTSetVarBlock name="monthentries">

<MTArchiveYearIfEntries>

<MTGridCell>
<MTGridIfLeftColumn><tr></MTGridIfLeftColumn>

<td width="25%" valign="top">

<span class="green-header"><$MTArchiveDate format="%b %Y"$></span>

<table align="center" border="0" cellspacing="0" cellpadding="3">

<TR>
<TD class="calendar-header">S</TD>
<TD class="calendar-header">M</TD>
<TD class="calendar-header">T</TD>
<TD class="calendar-header">W</TD>
<TD class="calendar-header">T</TD>
<TD class="calendar-header">F</TD>
<TD class="calendar-header">S</TD>
</TR>

<MTCalendar month="this">

<MTCalendarWeekHeader>
<tr>
</MTCalendarWeekHeader>

<TD class="calendar-date">

<MTCalendarIfEntries>


<MTEntries category="entertainment" lastn="1">

<a href="<$MTEntryLink archive_type="Daily"$>" onMouseover="window.status='read entries for this day'; return true" onMouseout="window.status=''; return true" title="read entries for this day"><$MTCalendarDay$></A>
</MTEntries>

<MTIfNotEmpty var="monthentries">
...go ahead and display this month
</MTIfNotEmpty>


</MTCalendarIfEntries>

<MTCalendarIfNoEntries>
<$MTCalendarDay$>
</MTCalendarIfNoEntries>

<MTCalendarIfBlank>
 
</MTCalendarIfBlank>

</td>

<MTCalendarWeekFooter>
</tr>
</MTCalendarWeekFooter>

</MTCalendar>
</table>

</td>

<MTGridIfRightColumn></tr></MTGridIfRightColumn>
</MTGridCell>

</MTArchiveYearIfEntries>

</MTSetVarBlock>

</MTArchiveYear>

<MTGridTrailingCells>
<MTGridIfLeftColumn><tr></MTGridIfLeftColumn>
<td> </td>
<MTGridIfRightColumn></tr></MTGridIfRightColumn>
</MTGridTrailingCells>
</MTGrid>
</table>

<br><br>


I'm not sure if I have the tags in the right spots, it was tricky with all the other things going on. Also, I have this as a monthly archive template instead of an index template- does it matter? Currently, I have this code (without the SetVar tags) as a monthly archive template and it outputs a file for each year (2004.php, etc.) and then I include those in a main index template. But for some reason now it's showing just a blank page.

My brain is swimming with tags..heh. Help?
mutedgirl
I figured it out! I don't know why I didn't think of this before. I simply used the MTIfNotEmpty tag again, this time for the entire calendar section. And I did it in an index template rather than an archive template. Here's what I did:

CODE
<table align="center" border="0" cellpadding="12" cellspacing="0">

<MTGrid num_columns="4">

<MTArchiveList archive_type="Monthly">

<MTEntries lastn="1">
<MTIfNotEmpty var="EntryBody">

<MTGridCell>
<MTGridIfLeftColumn><tr></MTGridIfLeftColumn>

<td width="25%" valign="top">

<span class="green-header"><$MTArchiveDate format="%b %Y"$></span>

<table align="center" border="0" cellspacing="0" cellpadding="3">

<TR>
<TD class="calendar-header">S</TD>
<TD class="calendar-header">M</TD>
<TD class="calendar-header">T</TD>
<TD class="calendar-header">W</TD>
<TD class="calendar-header">T</TD>
<TD class="calendar-header">F</TD>
<TD class="calendar-header">S</TD>
</TR>

<MTCalendar month="this">

<MTCalendarWeekHeader>
<tr>
</MTCalendarWeekHeader>

<TD class="calendar-date">

<MTCalendarIfEntries>

<MTEntries lastn="1">
<MTIfNotEmpty var="EntryBody">
<a href="<$MTEntryLink archive_type="Daily"$>" onMouseover="window.status='read entries for this day'; return true" onMouseout="window.status=''; return true" title="read entries for this day"><$MTCalendarDay$></A>
</MTIfNotEmpty>
<MTIfEmpty var="EntryBody">
<$MTCalendarDay$>
</MTIfEmpty>
</MTEntries>

</MTCalendarIfEntries>

<MTCalendarIfNoEntries>
<$MTCalendarDay$>
</MTCalendarIfNoEntries>

<MTCalendarIfBlank>
 
</MTCalendarIfBlank>

</td>

<MTCalendarWeekFooter>
</tr>
</MTCalendarWeekFooter>

</MTCalendar>

</table>

</td>

<MTGridIfRightColumn></tr></MTGridIfRightColumn>
</MTGridCell>

</MTIfNotEmpty>
</MTEntries>

</MTArchiveList>

<MTGridTrailingCells>
<MTGridIfLeftColumn><tr></MTGridIfLeftColumn>
<td> </td>
<MTGridIfRightColumn></tr></MTGridIfRightColumn>
</MTGridTrailingCells>

</MTGrid>
</table>


And it works wonderfully! Here it is: http://www.muted.com/history

Thanks for your help- it got me thinking down other paths that led me to the solution. smile.gif
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.