I have a bunch of zClass instances and I want to display only the ones that match all three criterion (approved=1, goLiveDate<=ZopeTime(), expired=0). I'm not exactly sure how to do this. I have tried <dtml-if> statements inside the <dtml-in></dtml-in> statements but the "in", even though it does not show the files that don't match, still counts all of them which messes up the next and previous. How do I write my code to correctly show and count only the matching instances? I have searched both the zope.org site and the eGroups list for the answer and if it is there I can't find it :-( Thanks!! Jamey Here is the code. <dtml-in "PARENTS[0].objectValues(['PressRelease'])" sort="goLiveDate" reverse size="5" start="batch_start" next> <p> <a href="&dtml-URL;&dtml-sequence-query;batch_start=&dtml-next-sequence-start-n umber;"> Next &dtml-next-sequence-size; older Releases </a> </dtml-in> <dtml-in "PARENTS[0].objectValues(['PressRelease'])" sort="goLiveDate" reverse size="5" start="batch_start"> <dtml-if "goLiveDate <= ZopeTime"> <p><b><a href="<dtml-var "id">/release.html"> &dtml-pr_title; </a></b> - <dtml-var goLiveDate fmt="%m/%d/%Y"><br> <font size="2">&dtml-summary;</font> </p> </dtml-if> </dtml-in> <dtml-in "PARENTS[0].objectValues(['PressRelease'])" sort="goLiveDate" reverse size="5" start="batch_start" previous> <p> <a href="&dtml-URL;&dtml-sequence-query;batch_start=&dtml-previous-sequence-sta rt-number;"> Next &dtml-previous-sequence-size; more recent Releases </a> </dtml-in>
Hi I had the same problem and found out there is no way yet of making dtml-in with multiple conditions. Instead I had to do dtml-if's and make my own counter and previous/next attributes to handle the batches. Peter Webmaster skrev:
I have a bunch of zClass instances and I want to display only the ones that match all three criterion (approved=1, goLiveDate<=ZopeTime(), expired=0). I'm not exactly sure how to do this. I have tried <dtml-if> statements inside the <dtml-in></dtml-in> statements but the "in", even though it does not show the files that don't match, still counts all of them which messes up the next and previous. How do I write my code to correctly show and count only the matching instances?
I have searched both the zope.org site and the eGroups list for the answer and if it is there I can't find it :-(
Thanks!!
Jamey
Here is the code.
<dtml-in "PARENTS[0].objectValues(['PressRelease'])" sort="goLiveDate" reverse size="5" start="batch_start" next> <p> <a href="&dtml-URL;&dtml-sequence-query;batch_start=&dtml-next-sequence-start-n umber;"> Next &dtml-next-sequence-size; older Releases </a> </dtml-in>
<dtml-in "PARENTS[0].objectValues(['PressRelease'])" sort="goLiveDate" reverse size="5" start="batch_start"> <dtml-if "goLiveDate <= ZopeTime"> <p><b><a href="<dtml-var "id">/release.html"> &dtml-pr_title; </a></b> - <dtml-var goLiveDate fmt="%m/%d/%Y"><br> <font size="2">&dtml-summary;</font> </p> </dtml-if> </dtml-in>
<dtml-in "PARENTS[0].objectValues(['PressRelease'])" sort="goLiveDate" reverse size="5" start="batch_start" previous> <p> <a href="&dtml-URL;&dtml-sequence-query;batch_start=&dtml-previous-sequence-sta rt-number;"> Next &dtml-previous-sequence-size; more recent Releases </a> </dtml-in>
_______________________________________________ Zope maillist - Zope@zope.org http://lists.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://lists.zope.org/mailman/listinfo/zope-announce http://lists.zope.org/mailman/listinfo/zope-dev )
I had the same problem and found out there is no way yet of making dtml-in with multiple conditions. Instead I had to do dtml-if's and make my own counter and previous/next attributes to handle the batches.
One way to simplify this is to use two dtml-in loops. The first one filters out the items you want to include, then the second one just displays all the items in the filtered loop. So instead of: <dtml-in sequence><dtml-if "somecomplexcondition"> messing around with counters and stuff goes here... </dtml-if></dtml-in> You have something like: <dtml-let seq="[]"> <dtml-in sequence><dtml-if "somecomplexcondition"> <dtml-call "seq.append((_['sequence-key'], _['sequence- item']))" </dtml-if></dtml-in> <dtml-in seq> Put your real loop body here. </dtml-in> </dtml-let> The second sequence then has the correct counter, and you can use the next/prev batches on it as well if you want. When building the second sequence you have a choice of how to structure it. If you simple append sequence-item, this should work, unless the sequence items are two element tuples. If you append a tuple as shown this should work every time. It can also be useful to calculate a new key, for example if you wanted to sort the list on more than one field you could build a key from the sorted fields. The main downside to this scheme is that you have to process the whole list, which could be annoying if you just want a small batch from the front of a long list. -- Duncan Booth duncan@dales.rmplc.co.uk int month(char *p){return(124864/((p[0]+p[1]-p[2]&0x1f)+1)%12)["\5\x8\3" "\6\7\xb\1\x9\xa\2\0\4"];} // Who said my code was obscure? http://dales.rmplc.co.uk/Duncan
On Tue, 1 Aug 2000, Webmaster wrote:
I have a bunch of zClass instances and I want to display only the ones that match all three criterion (approved=1, goLiveDate<=ZopeTime(), expired=0).
One way to accomplish this is by using ZCatalog. Index those properties, and specify your selection criteria in the Catalog call. If the properties change a lot, though, you are going to increase the amount of data getting written to your FileStorage on each change. --RDM
participants (4)
-
Duncan Booth -
Peter Arvidsson -
R. David Murray -
Webmaster