Hi Loren, J. Atwood, Maik

Thanks for all the info! I'll digest & give feedback 
where I can. In the meantime, this is what I've fixed up
for myself (with a LOT of help from Roche Compaan) ..

In DTML Document 'index_html'::

    <dtml-var docsSorted> 

In DTML Method 'docsSorted'::

    <dtml-if "REQUEST.form.has_key('sort_key')">
        <dtml-call "REQUEST.set('sort_key', REQUEST.form['sort_key'])">
        <dtml-call "RESPONSE.setCookie('sort_key',
        <dtml-if "REQUEST.cookies.has_key('sort_key')">
            <dtml-call "REQUEST.set('sort_key',
            <dtml-call "RESPONSE.setCookie('sort_key', 'title')">
            <dtml-call "REQUEST.set('sort_key', 'title')">
        </dtml-if "REQUEST.cookies.has_key['sort_key']">
    </dtml-if "REQUEST.form.has_key('sort_key')">

    <table border="1">
    <tr>  <th> <a href="<dtml-var id>?sort_key=title">Title</a>
        </th> <th> <a href="<dtml-var id>?sort_key=origin">Origin</a>
        </th> <th> <a href="<dtml-var id>?sort_key=series">Series</a>

    <dtml-if "sort_key=='title'">
        <dtml-in "PARENTS[0].objectItems(['ccDocClass'])" size=10 start=qs
        <tr> <td> 
        <a href="<dtml-var id>"><dtml-var title></a> 
        <dtml-if "AUTHENTICATED_USER.has_role('ContentManager')">
            [<b><a href="<dtml-var id>/manage_workspace">Edit</a></b>]
        </td> <td> <dtml-var origin> </td> <td> <dtml-var series> </td>
    <dtml-elif "sort_key=='series'">
        <dtml-in "PARENTS[0].objectItems(['ccDocClass'])" size=10 start=qs
        <tr> <td> 
    [... and so on for the other possibilities ...]

The rationale is:

'docsSorted' is called as method by 'index_html'. 
- Upon the first iteration, there is no cookie and no form
    variable. A cookie and a form variable is set to 'title' as
    default. The form variable governs.
- Upon subsequent iterations, if there is a form variable,
    then 'index_html' was called from 'docsSorted' and the
    sort-order has *just* changed. The cookie is changed (which
    will not be noticed during this iteration since it first has
    to be received again) and the form variable governs.
- If there is a only a cookie and no form variable, it

Now I want to extend it so that choosing a sort-order for the
*second* time reverses the order -- does this really entail 
repeating the entire '<dtml-if "sort_key=='title'">' section
for '"order=='reverse'"'?

I think I'm probably better off using the catalog for this,
rather than dtml-in batching .. 

Jean Jordaan       --    technical writer    --
Mosaic Software    --    Zope 2.1.6 on WinNT and W2K

Zope maillist  -  [EMAIL PROTECTED]
**   No cross posts or HTML encoding!  **
(Related lists - 
 http://lists.zope.org/mailman/listinfo/zope-dev )

Reply via email to