There are a couple of ways of using Movable Type to create a calendar of events.
One is to display future events as text entries, replacing the traditional
bloggish today-going-backwards posting order. The key to this is the fact that
MT allows you to change the date on a post, even to a future one. The other
way is to change a blog’s monthly archive template to display in a calendar-style
layout.
Note that if you want your events calendar to appear in a sidebar of your
existing text blog, you will need to create a separate blog for the calendar
and use includes to put it on your index page. The instructions below will
change the configuration of your entire blog. Use at your own risk!
Part one: the future events listing
Example: Exploit Boston
With the default MT settings, your events will display entries from the farthest
in the future and backwards. To turn it around and display posts from now going
forward, go to Blog Config -> Preferences and change the order of posts to “Ascending.” Another
(less drastic) way of doing this is to rewrite your MTEntries tag:
There are two ways to show the upcoming events and hide the past ones: categories
(manual) or date-based (automatic, requires PHP).
For categories:
Establish a category for current/upcoming events. (We’ll call it ‘upcoming’).
If you don’t have any other categories, create some (like ‘deadlines’ or ‘events’).
In your main index template, change <$MTEntries> to
Now the only entries that will be displayed are those that are in the Upcoming
category. You will need to edit each entry and remove it from the Upcoming
category in order for the entry to “expire.”
When you post an entry, assign its primary category as something other than
upcoming. Save it. Now edit the entry and change the date to the date of your
event, and use the “assign multiple categories” button to assign
it to Upcoming. Save the entry again.
When the event has passed, edit the entry again and remove it from the Upcoming
category.
For automatic expirations using PHP:
Again, two options here. You can have posts expire at a time you set, down
to the second, on the day they take place; or you can have them expire at
the end of the day. (If you don’t really care, go with the second option;
it’s much easier to maintain.)
Option 1:
In your template, add this PHP snippet inside your
. . (keep your existing code here) . } ?>
(source: Scriptygoddess) Be sure to change your template’s output file to .php if it wasn’t Note that because the PHP code compares the time stamps down to the |
Option 2:
In your template, add this PHP snippet inside your
. . (keep your existing code here) . } ?>
Be sure to change your template’s output file to .php if it wasn’t See this |
Archives will always go from latest to earliest, even if you change the display
order of your posts in your preferences. You can check this
thread for some ways to rearrange your archives using PHP.
Relevant threads on the MT support forum:
Setting
up Exploit Boston
[updated Feb. 10, 2003]
Next up: How to display your calendar as a calendar instead of a text listing…
-lc- says
figured out my own answer, just modify the $now time to use yesterday in the comparison:
date(“Ymd”,time()-24*3600);
tested working, I think, not sure how it handles issues like the 1st of the month minus 1, etc
-lc- says
Thanks Steph… hey can you take a peek at my question on the MT forum about showing mini calendars for future events, but only the next 3 months, instead of the last 3 future month stored.
http://www.movabletype.org/support/index.php?act=ST&f=14&t=25953
MT insists on showing October, November, December
when it should be showing August, September, October. I suspect I am going to have to show ALL months and filter out using PHP – not sure how t handle it when it crosses years. This also might be a problem when there are years worth of past entries. Cannot seem to find a plugin to work around this, CalenderEx has the same issues.
-lc- says
Thanks for all the info and help here. I have successfully extended the MT full screen calendar concept to display future events and gave it the ability to create new entries for any given date with a single click:
http://www.movabletype.org/support/index.php?act=ST&f=14&t=26633#entry123670