How to implement a round through the whole web site
Hi, I want to add a round to a small Zope based web site. Therefor I would like to add a prev and a next button on each page. So it is possible to start on the first page and then move on to the next one by clicking on the next button. After some clicks on the next button I'm sure to have visited all pages. I want to realize this goal through adding an attribute named sequence (´seq´) to every DTML document that should be reached through the round. The value is a 4 digit number that defines the order in which the pages should appear. Then I've started to implement a method using DTML to generate the hyperlinks for prev/next. The strategy would be to determine the sequence number of the actual document. Afterwards all documents are searched and each id is compared to the actual one. The results should be saved in variables that could be used to set up the links after all documents have been processed. My problem is now how to store the intermediate results in variables. I'm able to define a variable (myseq), but I'm not able to change the value afterwards: <-------- snip <dtml-call "REQUEST.set('myseq', 7L)"> <dtml-if "_.has_key('seq')"> <dtml-call "myseq = seq"> <-- wrong!!! Seq: <dtml-var seq>/ <dtml-else> sequence is missing! </dtml-if> <dtml-var myseq> <-------- snap What is the most efficient way to traverse all DTML documents in a given branch of a Zope server? Today I use something like this: <dtml-in "krawczak.objectItems('Folder')" sort=id> <dtml-in "objectItems('Folder')" sort=id> <dtml-in "objectItems('DTML Document')" sort=id> <br> <dtml-var id>, Properties: <dtml-in "propertyMap()"> <dtml-var "_['sequence-item']['id']">, </dtml-in> </dtml-in> </dtml-in> </dtml-in> Are there better solutions? Do you know of a predefined way to implement the round through the web site? Thank you Christian -- Dipl.-Ing. Christian Leutloff, Aachen, Germany christian@leutloff.de http://www.oche.de/~leutloff/ leutloff@debian.org Debian GNU/Linux - http://www.de.debian.org/
On 25 Aug 2000, Christian Leutloff wrote:
My problem is now how to store the intermediate results in variables. I'm able to define a variable (myseq), but I'm not able to change the value afterwards:
<-------- snip <dtml-call "REQUEST.set('myseq', 7L)">
<dtml-if "_.has_key('seq')"> <dtml-call "myseq = seq"> <-- wrong!!!
You're going to kick yourself on this one <grin>: <dtml-call "REQUEST.set('myseq', seq)">
Are there better solutions?
Do you know of a predefined way to implement the round through the web site?
Given your description, which I'm not sure I completely understand, I'd suggest adding a Catalog to your site, and creating an index field in the catalog that indexes your document sequence number. Also make a meta data property in the catalog for the index field. To get your complete list of documents, just call the catalog, and you'll get back everything indexed. (If you index more stuff than your documents, just query the Catalog for meta_type DTMLDocument, or query your index field for >0 and <maxval.) <dtml-in Catalog sort=indexfield> do your processing </dtml-in> Take a look at the Catalog HowTo's to decide what stuff you want in meta data fields and how to get the object given its Catalog pointer if you decide you need to do that. Hmm. To do prev and next buttons you could find the right document by doing a search on your index field for a value less then the current id (prev), sort in reverse, and do size=1 on the dtml-in. For next, do >id and normal sort order and again size=1. --RDM
Christian Leutloff wrote:
Hi,
I want to add a round to a small Zope based web site. Therefor I would like to add a prev and a next button on each page. So it is possible to start on the first page and then move on to the next one by clicking on the next button. After some clicks on the next button I'm sure to have visited all pages.
I want to realize this goal through adding an attribute named sequence (´seq´) to every DTML document that should be reached through the round. The value is a 4 digit number that defines the order in which the pages should appear. Then I've started to implement a method using DTML to generate the hyperlinks for prev/next. The strategy would be to determine the sequence number of the actual document. Afterwards all documents are searched and each id is compared to the actual one. The results should be saved in variables that could be used to set up the links after all documents have been processed.
My problem is now how to store the intermediate results in variables. I'm able to define a variable (myseq), but I'm not able to change the value afterwards:
I 'feel' like I may not know everything you're wanting to accomplish, but. By, 'small', do you mean 50 pages, 100 pages? How about each page gets an id that will put it in the proper order when it is appended to a list and then sequenced through? Start out with id's that are, maybe 10 numbers apart so that you can easily insert pages in the sequence with out renumbering the other pages. Or you could just as easily use your 'seq' property. Create and append to a list each of the pages sorted by id. Then your NEXT PREVIOUS links will be to; sequence-index +1 and sequence-index - 1. HTH, -- Tim Cook -- FreePM Project Coordinator http://www.freepm.org OS Health Care Alliance Supporter http://www.oshca.org
participants (3)
-
Christian Leutloff -
R. David Murray -
Tim Cook