[Zope-CMF] CMF sorting objects help

Eric Dunn endunn@rocketmail.com
Thu, 31 Jul 2003 18:55:03 -0700 (PDT)


Here is the latest code I tried to make work to sort
desc.

<div metal:define-macro="index_header">

  
  <div id="DesktopDescription"
tal:content="here/Description">
         Document Description goes here.
  </div>

</div>


<div metal:define-macro="index_content">

<div tal:define="auth_filter nocall:
modules/ZTUtils/LazyFilter;
                   default_types python:( 'Document'
                                        , 'Image'
                                        , 'File'
                                        , 'FAQ'
                                        , 'News Item'
                                        );
                   types types |
here/show_content_types | default_types;
                   raw_items python:
here.contentValues(
                   filter={'portal_type': types } );
                    sort_on
python:(('ModificationDate', 'cmp', 'asc'),
		   ('id', 'nocase', 'asc'));
		   sorted_items
python:sequence.sort(raw_items,sort_on);
                   items python: auth_filter(
raw_items, skip='View' );
                  ">

 <div tal:condition="items">



  <h4> Content </h4>

  <ul>
   <li tal:repeat="item items">
    <a href="item_url" tal:attributes="href
item/absolute_url"><img
      align="middle" border="0"
      tal:attributes="src  
string:${item/portal_url}/${item/getIcon};
                      alt   string:${item/Type};
                      title string:${item/Type}"></a>



    <a href="item_url" tal:attributes="href
item/absolute_url"
       tal:content="item/Title"> Title </a>
     <blockquote tal:condition="exists:
item/Description"
                 tal:content="item/Description">
       Description <!--fmt="structured-text'-->
     </blockquote>
   </li>
  </ul>

  </div>

  </div>

</div>
<div metal:define-macro="index_links">


<div tal:define="auth_filter nocall:
modules/ZTUtils/LazyFilter;
                   default_types python:( 'Document'
                                        , 'Link'
                                        , 'Favorite'
                                        , 'Topic'
                                        );
                   types types | here/show_link_types
| default_types;
                   raw_items python:
here.contentValues(
                                     filter={
'portal_type': types } );
                    sort_on
python:(('ModificationDate', 'cmp', 'asc'),
		   ('id', 'nocase', 'asc'));
		   sorted_items
python:sequence.sort(raw_items,sort_on);
                   items python: auth_filter(
raw_items, skip='View' );
                  ">


  <div tal:condition="items">
  <h4> Related Resources </h4>

  <ul>
   <li tal:repeat="item items">
    <a href="item_url" tal:attributes="href
item/absolute_url"><img
      align="middle" border="0"
      tal:attributes="src  
string:${item/portal_url}/${item/getIcon};
                      alt   string:${item/Type};
                      title string:${item/Type}"></a>
    <a href="item_url" tal:attributes="href
item/absolute_url"
       tal:content="item/Title"> Title </a>
     <blockquote tal:condition="exists:
item/Description"
                 tal:content="item/Description">
       Description <!--fmt="structured-text'-->
     </blockquote>
   </li>
  </ul>

  </div>
  </div>

</div>

<div metal:define-macro="index_folders">

  <div tal:define="auth_filter nocall:
modules/ZTUtils/LazyFilter;
                   default_types python:( 'Folder'
                                        , 
                                        );
                   types types |
here/show_folder_types | default_types;
                   raw_items python:
here.contentValues(
                            filter={ 'portal_type':
types } );
                   sort_on
python:(('ModificationDate', 'cmp', 'asc'),
		   ('id', 'nocase', 'asc'));
		   sorted_items
python:sequence.sort(raw_items,sort_on);
                   items python: auth_filter(
raw_items, skip='View' );
                  ">
  <div tal:condition="items">
  <h4> Content </h4>

  <ul>
   <li tal:repeat="item items">
    <a href="item_url" tal:attributes="href
item/absolute_url"><img
      align="middle" border="0"
      tal:attributes="src  
string:${item/portal_url}/${item/getIcon};
                      alt   string:${item/Type};
                      title string:${item/Type}"></a>
    <a href="item_url" tal:attributes="href
item/absolute_url"
       tal:content="item/TitleOrId"> Title </a>
     <blockquote tal:condition="exists:
item/Description"
                 tal:content="item/Description">
       Description <!--fmt="structured-text'-->
     </blockquote>
   </li>
  </ul>

  </div>
  </div>

</div>

<div metal:define-macro="news_box">

 <table class="NewsItems"
        cellspacing="0"
        cellpadding="0"
        border="0"
        width="100%">
 <tbody tal:define="news python: here.portal_catalog(
meta_type='News Item'
                                                    ,
sort_on='Date'
                                                    ,
sort_order='reverse'
                                                    ,
review_state='published'
                                                    );
                    Batch
python:modules['ZTUtils'].Batch;
		            global batch python:Batch(news, 10, 0,
orphan=1)">
  <tr>
   <td class="NewsBorder" width="1" rowspan="13"
bgcolor="#6699CC">
    <img src="spacer.gif" alt=" " width="1" height="2"
border="0">
   </td>
   <td valign="top" class="NewsTitle" width="100%">
     <b>News</b>
   </td>
  </tr>
  <tr class="NewsItemRow" tal:condition="news"
      tal:repeat="news batch">
   <td valign="top" wrap>
    <a href="" tal:attributes="href
python:news.getURL()"
       tal:content="news/Title"></a><br>
    <span tal:replace="news/Date">Date</span>
   </td>
  </tr>
  <tr class="NewsItemRow"
tal:condition="python:not(news)">
   <td valign="top">
<!-- News status here -->
     No news posted at this time.
   </td>
  </tr>
  <tr class="NewsItemRow">
   <td>
     <a href="recent_news">More...</a>
   </td>
  </tr>
</tbody>
</table>

</div>







--- Anton Hughes <Anton.Hughes@utas.edu.au> wrote:
> Hi Eric,
> 
> As it happens, I'd just done the same thing myself
> recently. Here is the
> code from index_html_utils I used to sort first on
> id then on date:
> 
> <div tal:define="auth_filter nocall:
> modules/ZTUtils/LazyFilter;
>                    default_types python:( 'Document'
>                                         , 'Image'
>                                         , 'File'
>                                         , 'FAQ'
>                                         );
>                    types types |
> here/show_content_types | default_types;
>                    raw_items python:
> here.contentValues(
>                                     
> filter={'portal_type': types } );
>  			sort_on python:(('id', 'nocase', 'asc'),
> ('bobobase_modification_time', 'cmp', 'desc'));
> 			sorted_items python:sequence.sort(raw_items,
> sort_on)
> 			items python: auth_filter( sorted_items,
> skip='View'
> );">
> 
> Hope that helps...
> 
> Anton                  
> 
> -----Original Message-----
> From: Eric Dunn [mailto:endunn@rocketmail.com]
> Sent: Friday, 1 August 2003 10:34 AM
> To: zope-cmf@zope.org
> Subject: [Zope-CMF] CMF sorting objects help
> 
> 
> Can anyone tell me how to sort the objects that are
> viewed on the first page of the CMF.
> I place "News Items" on the front page (as well as
> the
> News block).  The "News" block on the right of the
> screen lists the News latest to earliest.  I would
> like to sort items on the front page in the same
> manner.  They are earliest to latest right now and I
> cannot find the code that controls the sorting.
> I located the 
>
/ZOPE_INSTANCE/CMF/portal_skins/custom/index_html_utils
> 
> I found it displayed the front page content but I
> cannot get the code correct that sorts in desc
> manner.
> Can anyone help.
> Thanks
> 
> =====
> Eric N. Dunn
> other email: endunn@aol.com
> 
> __________________________________
> Do you Yahoo!?
> Yahoo! SiteBuilder - Free, easy-to-use web site
> design software
> http://sitebuilder.yahoo.com
> 
> _______________________________________________
> Zope-CMF maillist  -  Zope-CMF@zope.org
> http://mail.zope.org/mailman/listinfo/zope-cmf
> 
> See http://collector.zope.org/CMF for bug reports
> and feature requests


=====
Eric N. Dunn
other email: endunn@aol.com

__________________________________
Do you Yahoo!?
Yahoo! SiteBuilder - Free, easy-to-use web site design software
http://sitebuilder.yahoo.com