Help - Search - Members - Calendar
Full Version: Grouping today's entries on homepage via links
Movable Type Community Forum > Additional Resources > Tips and Tricks
capricious
I'm using MT  to manage an event calendar at exploitboston.com.  I'm trying to list the most recent date stamp plus that day's events (aka "Today's Events") via links at the top of the homepage.  I thought bschoate's Perl plugin would be good for this (I'm using it to reverse the order of "browse by week" and "browse by month" and it works quite well). Or maybe there's an easier way.  I can't figure it out!

I'd like it to look like this:

CODE
<strong>Monday, November 11, 2002</strong>
<a href="#" title="link to the entry's individual page">Title of the first event for today goes here</a>
<a href="#" title="link to the entry's individual page">Title of the second event for today goes here</a>


Thanks for any tips you can provide!
kadyellebee
If you have daily archives turned out, here's an easy way to do it:
CODE
<MTArchiveList archive_type="Daily">
<strong><$MTArchiveDate$></strong><br>
<MTEntries>
<a href="<$MTEntryLink$>"><$MTEntryTitle$></a><br>
</MTEntries>
<br>
</MTArchiveList>

smile.gif
Kristine
capricious
Thanks for the help, Kristine!

The code you shared is listing every date and not just the latest.  I tried to use lastn="1" inside the MTEntries tag so that it would reflect "Today's Events" (or at least the most recent events coming up); but that didn't help.

Here's what the code looks like with my small additions for lastn, date format and sort_order (only the date format is working out of the three):

CODE
<MTArchiveList archive_type="Daily">

<strong><$MTArchiveDate format="%A, %B %d %Y"$></strong>

<MTEntries lastn="1" sort_order="descend">
<a href="<$MTEntryLink$>"><$MTEntryTitle$></a>
<br />

</MTEntries>
<br />
</MTArchiveList>


Here's the test page:

homepage with "Today's Events" test

smile.gif

Sooz
girlie
Try this:

CODE
<MTArchiveList archive_type="Daily" lastn="1">

<strong><$MTArchiveDate format="%A, %B %d %Y"$></strong>

<MTEntries sort_order="descend">
<a href="<$MTEntryLink$>"><$MTEntryTitle$></a>
<br />

</MTEntries>
<br />
</MTArchiveList>
capricious
So close!

The only thing left is that it should be listing the most recent entry.  For some reason MT insists on listing the entry that is farthest in the future.  (It's listing an event on December 20th instead of November 14th.)

I am most definately a novice when it comes to MT. Thanks so much for all your help!

How it looks on the web
kadyellebee
Sorry about that, I misunderstood your initial question!  
Girlie's suggestion would be what I would have thought.  But I'm not sure what to do with future entries!

Kristine
capricious
No worries. I doubt my question was all that clear. I'd love to see examples of MT used as an event calendar if anyone else is doing something like this!

It seems like I need a variation of this (as provided by Brad Choate in the support forum on 11/4 here); but with the MTEntries stuff, too, so that the entry title is displayed and not the archive title.  I'm sure there is some way or another to do this.  Maybe. wink.gif

CODE
<MTPerlScript>
my @list;
<MTArchiveList archive_type="Monthly"'>
push @list, q{<a href="<$MTArchiveLink$>"><$MTArchiveTitle$></a> (<$MTArchiveCount$>)}."\n";
</MTArchiveList>
print foreach reverse @list;
</MTPerlScript>
bschoate
Here's what I came up with:
CODE
<strong>Today's Events (<MTDate format="%A, %B %e %Y">)</strong>

<p>
<MTCalendar><MTCalendarIfToday><MTCalendarIfEntries>
 <MTEntries><a href="<MTEntryLink>"><MTEntryTitle></a>
</MTEntries><MTElse><em>No events for today</em>
</MTElse></MTCalendarIfEntries></MTCalendarIfToday></MTCalendar>
</p>
It has to be rebuilt daily of course, but a script could be used to automate that.

(Edited to remove the unnecessary 'month="this"' attribute for index templates.)
capricious
Thanks for the help, Brad!!!!

I inserted your code and when I rebuilt the index pages, I got this error message in the popup:

An error occurred:

Build error in template 'index-with-daily': Error in <MTCalendar> tag: You used an <MTCalendar month="this"> tag without a date context set up.


I wonder if I need to add something else?

Here's what the page's html looks like:

CODE
<$MTInclude module="headerstuff"$>


<div id="content">

<div class="blog">




<h2>Today's Events (<MTDate format="%A, %B %e %Y">)</h2>

<p>
<MTCalendar month="this"><MTCalendarIfToday><MTCalendarIfEntries>
<MTEntries><a href="<MTEntryLink>"><MTEntryTitle></a>
</MTEntries><MTElse><em>No events for today</em>
</MTElse></MTCalendarIfEntries></MTCalendarIfToday></MTCalendar>
</p>





<MTEntries>
<$MTEntryTrackbackData$>

    <MTDateHeader>
    <h2 class="date">.:
<$MTEntryDate format="%x"$> :.
    </h2>
    </MTDateHeader>

    <div class="blogbody">
    
    <a name="<$MTEntryID pad="1"$>"></a>
    <h3 class="title"><$MTEntryTitle$></h3>

<p>Filed under: <a href="<$MTEntryLink archive_type="Category"$>">
<$MTEntryCategory$></a>
</p>    
    <$MTEntryBody$>


    
    <MTEntryIfExtended>
    <p><a href="<$MTEntryPermalink$>">Additional event details for  "<$MTEntryTitle$>"</a></p>
    </MTEntryIfExtended>

    

<$MTInclude module="posted"$>
    
</div>
    
</MTEntries>

</div>

</div>

<$MTInclude module="sidebar"$>
jlm
It looks like you might need the MTDateHeader and /MTDateHeader tags around that MTDate format code after "Today's Events".
girlie
The problem is that on an index page, MT doesn't know which month "this" is. From the manual:

QUOTE
This tag takes an optional attribute month, which, if present, specifies the desired calendar month and year. If the value of this attribute is the string this, the calendar will be created in the surrounding date context; this means that, for example, in an archive template, you can use

<MTCalendar month="this">
...
</MTCalendar>

to represent the calendar for the month of the archive currently being viewed. This will work for Individual, Daily, Weekly, and Monthly archives, not for Category archives.


If you want the calendar to display for the current month on an Index Template, remove the month="this" attribute.
bschoate
Yep, that's what I was trying to do. Removing the month="this" should do it.  Thanks girlie!
girlie
Aww, it's the least I could do for the guy who created all those fine plugins!  wink.gif
capricious
Awesome! It works now! Now I just need to fine tune the formatting.

You all rock. 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.