Hi Johan,
There may be a TT2 module which does what you need to do, but I think
that templating is the wrong approach to producing something like a
calendar. Instead, I think an "HTML DOM" approach is much cleaner and
flexible.
For instance, suppose you had a $table object which acted like an HTML
TABLE DOM object, and then you wrapped that in a $cal object so that
you could access TD elements of $table by their date (it mapped dates
to table cells). Code to generate the calendar you refer to might look
like this:
for my $d (dates in the current month) {
my $td = $cal->find_cell_for_date($d);
if (date has an event) {
$td->inner_html(...anchor html...);
} else {
$td->inner_html( $d->day_of_month);
}
}
print $cal->get_table->as_html;
Now this is probably easy to do in a templating system, but what if
you wanted to extend it by setting the background color of event dates
to a different color or style? This approach makes that easy:
for my $d (dates in the current month) {
my $td = $cal->find_cell_for_date($d);
if (date has an event) {
$td->inner_html(...anchor html...);
$td->set_css("style: ...");
} else {
$td->inner_html($d->day_of_month);
}
}
print $cal->get_table->as_html;
Another advantage is that you could make the calendar generation
driven by your events:
# first put in the date numbers
for my $d (dates in current month) {
my $td = $cal->find_cell_for_date($d);
$td->inner_html(...$d->day_of_month...);
}
# now add the events
for my $e (list of events) {
my $td = $cal->find_cell_for_date($e->date);
$td->append_inner_html(...$e->title...);
$td->set_css("...");
}
print $cal->get_table->as_html;
The DOM approach makes it easy to add additional "passes" to build up
your calendar, and you can't do that with templating.
Anyway, just my two cents...
ER
On Mon, Apr 27, 2009 at 1:31 PM, Johan Vromans <[email protected]> wrote:
> Hi,
>
> Is there a TT2 plugin that can generate a nice monthly calendar with
> links for date related documents, something similar to
> http://www.squirrel.nl/pub/xfer/webcal.html ?
>
> -- Johan
>
>
> _______________________________________________
> templates mailing list
> [email protected]
> http://mail.template-toolkit.org/mailman/listinfo/templates
>
_______________________________________________
templates mailing list
[email protected]
http://mail.template-toolkit.org/mailman/listinfo/templates