You are here:   » Home » Documentation » Details » How-To » TOC-Lists » Home

List current documents of the last 14 days

Author: Dirk Nordmann, Dr. F. Hoffmann, 2003/10/24

The most recent page objects of the last 14 days shall appear in a sorted list over the entire content tree.

Solution: A sorted list, limted to the dated time period, is written on the node to be checked (in the examplary code the root element 'content') with filteredTreeNodes(). The code is put into a text section (HTML format); alternatively the code can be written in a Teasertext element (and the entry path can be corrected e.g. with getParentNode().getParentNode().filteredTreeNodes).

<dtml-call "REQUEST.set('res',[])">
   <dtml-call "REQUEST.set('curr_dt',ZopeTime())">
   <dtml-call "REQUEST.set('curr_dt', 
    _.DateTime('%4d/%2d/%2d'%(curr_dt.year(),curr_dt.month(),curr_dt.day())))">
   <dtml-call "REQUEST.set('curr_dt',curr_dt.timeTime())">
   <dtml-call "REQUEST.set('delta_dt',REQUEST.get('days',14)*24*60*60)">
   <dtml-in "content.filteredTreeNodes(REQUEST,None,'attr_active_start','desc')">
    <dtml-let ob=sequence-item>
     <dtml-call "REQUEST.set('start_dt',
      getObjProperty('attr_active_start',REQUEST))">
     <dtml-if start_dt>
      <dtml-call "REQUEST.set('start_dt', 
       _.DateTime('%4d/%2d/%2d'%(REQUEST['start_dt'][0],  
       REQUEST['start_dt'][1],REQUEST['start_dt'][2])))">
      <dtml-call "REQUEST.set('start_dt',REQUEST['start_dt'].timeTime())">
      <dtml-if "curr_dt-REQUEST['start_dt']<=delta_dt">
       <dtml-call "res.append(ob)">
      </dtml-if>
     </dtml-if>
    </dtml-let>
   </dtml-in>
   <!-- generate html code -->
   <hr size="1"/>
   <div class="form-small">
   <b>Aktuelle Dokumente:</b>
   <br/>
   <dtml-in res>
    <dtml-let ob=sequence-item>
     <a href="<dtml-var "getHref2IndexHtml(REQUEST)">">
     <dtml-var "getTitle(REQUEST)"></a>
     <dtml-var "getLangFmtDate(getObjProperty('attr_active_start',
     REQUEST),lang,'DATE_FMT')">
     <dtml-if "getObjProperty('attr_dc_description',REQUEST)">
     <br /><dtml-var "getObjProperty('attr_dc_description',REQUEST)">
     </dtml-if>
     <br />
    </dtml-let>
   </dtml-in>
   </div>
   <hr size="1"/>

Comment: Attention: iteration over all objects can cause considerable computing times in case of a great number of documents