[Zope-CMF] CMFCalender and monthRange Probs

Joseph Wayne Norton norton@alum.mit.edu
Fri, 24 Aug 2001 00:23:16 +0900


Marc -

If you do not want to use the monthRange external method, then do
something like the following in the dtml script ... see the csdate and
cedate variables.  The csdate and cedate are stored in the REQUEST.
It is probably less efficient but doesn't require an external method.

- j

<dtml-if marker-calendar>
  <dtml-call "REQUEST.set('mdate', REQUEST.get('marker-calendar'))">
</dtml-if>

<dtml-call "REQUEST.set('ThisPath', _.string.join(this().getPhysicalPath(), '/'))">
<dtml-let HomeFolder="this().portal_membership.getHomeFolder()">
  <dtml-if "HomeFolder != _.None">
     <dtml-let HomeFolderPath="_.string.join(HomeFolder.getPhysicalPath(), '/')">
        <dtml-if "_.string.find(REQUEST.get('ThisPath'), HomeFolderPath, 0) == 0">
           <dtml-call "REQUEST.set('review_state','')">
        <dtml-else>
           <dtml-call "REQUEST.set('review_state','published')">
        </dtml-if>
     </dtml-let>
  <dtml-else>
    <dtml-call "REQUEST.set('review_state','published')">
  </dtml-if>
</dtml-let>

<dtml-calendar modes="week,month,year" controls="yes">
  <dtml-unless csdate>
    <dtml-call "REQUEST.set('csdate', date)">
  </dtml-unless>
  <dtml-call "REQUEST.set('cedate', date)">

  <dtml-call "setCalendar('valign','top')">
  <dtml-call "setCalendar('daybgcolor','#CCCCCC')">
  <dtml-let d="date.dd()"
            m="date.mm()"
            y="date.year()"
            marker="_.str(y) + '-' + _.str(m) + '-' + _.str(d)"
            has_event="_.len(portal_catalog.searchResults( Type='Event'
                                                   , sort_on='start'
                                                   , sort_order='reverse'
                                                   , review_state=REQUEST.get('review_state')
                                                   , start=date.earliestTime()
                                                   , start_usage='range:min'
                                                   , end=date.latestTime()
                                                   , end_usage='range:max'
                                                   , path=REQUEST.get('ThisPath')
                                                   ))">

    <a href="<dtml-var "linkDate(date,mode)">&marker-calendar=<dtml-var marker>">
      <dtml-if "has_event > 0">
        <b><i><dtml-var d></i></b>
      <dtml-else>
        <dtml-var d>
      </dtml-if>
    </a>

  </dtml-let>
</dtml-calendar>

<p>

<dtml-if mdate>
  <dtml-call "REQUEST.set('date', _.DateTime(mdate))">
  <dtml-call "REQUEST.set('sdate', date)">
  <dtml-call "REQUEST.set('edate', date)">
  <dtml-call "REQUEST.set('period', date)">
<dtml-elif csdate>
  <dtml-call "REQUEST.set('sdate', csdate)">
  <dtml-call "REQUEST.set('edate', cedate)">
  <dtml-call "REQUEST.set('period', _.str(sdate) + ' - ' + _.str(edate))">
<dtml-else>
  <dtml-call "REQUEST.set('date', _.DateTime())">
  <dtml-call "REQUEST.set('sdate', date)">
  <dtml-call "REQUEST.set('edate', date)">
  <dtml-call "REQUEST.set('period', date)">
</dtml-if>

<table>
  <tr><th align="left">Events for &dtml-period;</th></tr>

  <dtml-in "portal_catalog.searchResults( Type='Event'
                                        , sort_on='start'
                                        , sort_order='reverse'
                                        , review_state=REQUEST.get('review_state')
                                        , start=sdate.earliestTime()
                                        , start_usage='range:min'
                                        , end=edate.latestTime()
                                        , end_usage='range:max'
                                        , path=REQUEST.get('ThisPath')
                                        )">
    <tr>
      <td valign="top">
        <a href="<dtml-var "getURL()">">&dtml-Title;</a>&nbsp;&nbsp;
        <dtml-var expr="getObject().start()" fmt=Date> 
          <dtml-if "getObject().start() != getObject().end()">
            - <dtml-var expr="getObject().end()" fmt=Date>
          </dtml-if>
        <br><dd>&dtml-Description;
      </td>
    </tr>
  <dtml-else>
    <tr>
      <td valign="top">
        There are no events listed.
      </td>
    </tr>
  </dtml-in>
</table>

</p>