Discussion:
[CalendarX-users] 3 month cal (prev, cur, next), label for prev
Mike Hammill
2006-10-02 14:27:14 UTC
Permalink
Hello all,

I am trying to modify my multimonth view to include the previous month,
the current month, and the month thereafter. My little hack got me the
three months I want, but there is no "label" for the first month shown;
instead, you see the title for the current month on both the top and
bottom of the whole three-month calendar as usual, which can be a little
disorienting in this particular situation. Exploring the .css files,
it really didn't jump out at me as to where I could add a label for the
first month, or if .css is really the place to begin. Any ideas?

Background:
I'm running CalendarX 0.6.6(stable), Plone 2.1.2, Zope (Zope
2.8.5-final, python 2.3.5, linux2). My little hack was to customize
getDictCommon by creating "mikeoffset" and replacing currentDate with it
as follows:

if viewname == 'multimonth':
mikeoffset = currentDate - 30
startDate = context.getStartOfMonth(mikeoffset)
endDate = context.getEndOfMonth(mikeoffset)
nextDate = (endDate + 1).Date()
prevDate = (startDate - 1).Date()
prevstring = 'previous month'
nextstring = 'next month'
currentstring = str(mikeoffset.Month())+' '+str(mikeoffset.year())
for monthnum in range(nummonths):
midmonth =
DateTime(str(mikeoffset.year())+'/'+str(mikeoffset.month())+'/15')
midmonth += monthnum*30
startDate = context.getStartOfMonth(midmonth)
startDateToShow = context.getStartOfMonthToShow(midmonth)
weeksInMonthToShow = context.getNumWeeksInMonthToShow(midmonth)
endDate = context.getEndOfMonth(midmonth)
endDateToShow = context.getEndOfDay(startDateToShow +
(7*weeksInMonthToShow) - 1)
startDateList.append(startDate)
endDateList.append(endDate)
startDateToShowList.append(startDateToShow)
endDateToShowList.append(endDateToShow)
weeksInMonthToShowList.append(weeksInMonthToShow)

I get a calendar with:

<< previous month October 2006 next month >>

[a calendar for September 2006 here]

October 2006
[a calendar for October 2006 here]

November 2006
[a calendar for November 2006 here]


<< previous month October 2006 next month >>

The header and footer (<< previous month October 2006 next
month >>) are no problem but what I would like is a label "September
2006" before the September calendar, just as there is for October and
November.

Any hints appreciated.
Best regards,
/Mike
+lupa+
2006-10-04 00:32:38 UTC
Permalink
Hi Mike,
It's easy (and sorry for the delay in answering). It's all in the
macro that gets called by the multimonth.pt template to generate the month
names. As written, if puts a "noshow" class TH tag in if the month == 0
(that is, for the first month on a multimonth calendar).

Go here: CX_props_macros.pt.
Find the macro called: monthnameformultimonths
Change this line:
tal:condition="python:mMonth > 0">
To this:
tal:condition="python:mMonth >= 0">

And remove (or comment out) the noshow TH tag at the bottom of the macro:
<th class="noshow"
tal:attributes="colspan python:7"
tal:condition="python:mMonth == 0"></th>

Of course, you could also just remove the TH noshow and remove the
tal:condition on the main TH tag too.
Looks great!
+lupa+
Post by Mike Hammill
Hello all,
I am trying to modify my multimonth view to include the previous month,
the current month, and the month thereafter. My little hack got me the
three months I want, but there is no "label" for the first month shown;
instead, you see the title for the current month on both the top and
bottom of the whole three-month calendar as usual, which can be a little
disorienting in this particular situation. Exploring the .css files,
it really didn't jump out at me as to where I could add a label for the
first month, or if .css is really the place to begin. Any ideas?
I'm running CalendarX 0.6.6(stable), Plone 2.1.2, Zope (Zope
2.8.5-final, python 2.3.5, linux2). My little hack was to customize
getDictCommon by creating "mikeoffset" and replacing currentDate with it
mikeoffset = currentDate - 30
startDate = context.getStartOfMonth(mikeoffset)
endDate = context.getEndOfMonth(mikeoffset)
nextDate = (endDate + 1).Date()
prevDate = (startDate - 1).Date()
prevstring = 'previous month'
nextstring = 'next month'
currentstring = str(mikeoffset.Month())+' '+str(mikeoffset.year())
midmonth =
DateTime(str(mikeoffset.year())+'/'+str(mikeoffset.month())+'/15')
midmonth += monthnum*30
startDate = context.getStartOfMonth(midmonth)
startDateToShow = context.getStartOfMonthToShow(midmonth)
weeksInMonthToShow = context.getNumWeeksInMonthToShow(midmonth)
endDate = context.getEndOfMonth(midmonth)
endDateToShow = context.getEndOfDay(startDateToShow +
(7*weeksInMonthToShow) - 1)
startDateList.append(startDate)
endDateList.append(endDate)
startDateToShowList.append(startDateToShow)
endDateToShowList.append(endDateToShow)
weeksInMonthToShowList.append(weeksInMonthToShow)
<< previous month October 2006 next month >>
[a calendar for September 2006 here]
October 2006
[a calendar for October 2006 here]
November 2006
[a calendar for November 2006 here]
<< previous month October 2006 next month >>
The header and footer (<< previous month October 2006 next
month >>) are no problem but what I would like is a label "September
2006" before the September calendar, just as there is for October and
November.
Any hints appreciated.
Best regards,
/Mike
Mike Hammill
2006-10-04 13:04:48 UTC
Permalink
Hi +lupa+!

Yes, you're right: your suggestions works and it looks great! Thanks
for the tip!

Best regards,
/Mike

PS I think you asked about seeing what sort of calendars we came up
with using CalendarX for our summer school in high-performance
computing. I never got around to fixing the problem of event locations
not showing up in the printed version, and I didn't quite have the
sub-calendar thing working quite right either. Thus, with a bit of
embarrassment (user error/neglect only; CalendarX performed great):

http://gannet.pdc.kth.se:8080/ss2006/schedule
(under "Calendar of Events")

Loading...