default userpic

Calendar of forthcoming events, now that DateTags is dead

Vote 0 Votes

Greetings --

I've been holding off my organization's upgrade to MT4 because I was hoping ScatterNation's DateTags would someday get upgraded. Sadly, it looks like that's not going to happen. So before I can make the now-urgently needed upgrade to MT4, I need to figure out the most efficient way to recreate the calendar of events page, which was dependent on that tag.

In our current setup, we use DateTags show the next 12 months' worth of entries, starting with the first day of the current month. There was a header for each month, showing the month's name, and a footer, which was just a gap in the layout. Like this:

JUNE
  12 Event 1
  14 Event 2
  14 Event 3
  21 Event 4

JULY
[...]

Each event in the calendar is an entry unto itself, with the date of the entry set to the date of the event. Some days will have more than one entry; most days will have no entry at all.

How do I do the same using the standard MT4 tags? Use MT:Calendar somehow, with a loop that runs 12 times and increments the month shown? I'm afraid I'm kind of at a loss here.

Many thanks for any help y'all can offer.

Reported on Movable Type 4.2

6 Replies

| Add a Reply
  • So have you tried DateTags and found that it doesn't work with MT4? Most MT3 plugins work just fine with MT4.

  • I saw this the other day, which may help you think in template tags about your problem: Publish only entries with dates (in) the future or past.

  • Thanks, Dan, for suggesting I just give it a go anyway. When it first appeared on the "not yet compatible" list on the Works with MT4 page, I took it at face value -- but lo and behold! It sort of works with MT4.2! (The DateRange tag, allowing for arbitrary start and end dates for entry printout, works. The MonthHeader and MonthFooter tags don't seem to work, which is a shame.)

    I'll look at the link that shenews provided with interest (my thanks), but in the mean time, here's the code we'll use for our calendar of events, in case it's useful to anyone else. In the absence of the DateTags function, I had to roll my own header/footer for each month's worth of entries.

    			<mt:SetVar name="header_month" value="banana" />
    			<mt:SetVar name="header_year" value="banana" />
    			<mt:SetVarBlock name="range_start"><mt:Date format="%m-01-%Y"></mt:SetVarBlock>
    		
    		<table>
    		<mt:DateRange start="$range_start" end="$range_start" end_adjust="364">
    			<mt:Entries>
    			<mt:SetVarBlock name="this_month"><mt:EntryDate format="%B" /></mt:SetVarBlock>
    			<mt:SetVarBlock name="this_year"><mt:EntryDate format="%Y" /></mt:SetVarBlock>
    				<mt:If var="header_month" ne="$this_month">
    					<mt:If var="header_month">
    						<tr>
    							<td>(blank spacer row that precedes each month header but the first one)</td>
    						</tr>
    					</mt:If>
    					<tr>
    						<td><b><mt:Var name="this_month"/>
    						<mt:SetVarBlock name="header_month"><mt:Var name="this_month" /></mt:SetVarBlock>
    						<mt:If var="header_year" ne="$this_year">
    							 <mt:Var name="this_year" />
    							 <mt:SetVarBlock name="header_year"><mt:Var name="this_year" /></mt:SetVarBlock>
    						</mt:If></b></td>
    					</tr>
    				</mt:If>
    						<tr>
    							<td>(table row containing event details)</td>
    						</tr>
    			</mt:Entries>
    		</mt:DateRange>
    		</table>
    
    

  • Hi Andrew -

    Though not as robust as Kevin's DateTags, the MT-SomeDays plugin works should work with MT4 (just make sure you get the most recent version): http://everitz.com/mt/somedays/index.php

    • Never did thank you for pointing me at MT-SomeDays. It works just fine in MT 4 -- all of its tags, rather than just some of them -- and although it's a couple seconds slower on the page rebuild it let me write much less kludgy code. So thanks!

  • For the benefit of future seekers: Chad Everett was correct, and MT-SomeDays also worked with MT4. As far as I could tell, SomeDays is slower: it added a couple of seconds to each rebuild of the page, but it also gave me clear, easy month headers and footers, rather than my having to create and compare all those variables. Much cleaner, more elegant code, which will make life easier for future maintainers of our website. The calendar code using SomeDays looked like this:

    		<mt:SetVarBlock name="range_start"><mt:Date format="%Y%m01"></mt:SetVarBlock>
    		
    		<table cellspacing="10" cellpadding="3" border="0" width=100%>
    		<MTSomeDays date="$range_start" select="+364">
    		<MTSDIfMonthStart>
    			<tr>
    				<td><$MTSDWorkDate format="%B"$></td>
    			</tr>
    		</MTSDIfMonthStart>
    			<mt:Entries>
    				<tr valign=top>
    					<td>(table row containing event details)</td>
    				</tr>
    			</mt:Entries>
    		<MTSDIfMonthEnd>
    			<tr>
    				<td>(blank spacer row)</td>
    			</tr>
    		</MTSDIfMonthEnd>
    		</MTSomeDays>
    		</table>
    
    

    Note that SomeDays tags don't parse in MT 4 if you use the new mt:TagName syntax. Stick with the old-school stuff.

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