[Zope] DMTL-IF: Listing Documents that contain queryword (Solution)

Sean Lee sean at erexi.com.tw
Mon Nov 24 10:08:22 EST 2003


Thanks to folks who responded to my question (as in Subject), especially
Jonathan and Dylan.
I've been trying to DMTL my way through this, on and off, for several
weeks.

Simply speaking, I have a bunch of files in a directory and I want to
(automatically) create URLs that will list groups of files by title so
that all files "Category A*" are listed together.

I decided to try the way of ZCatalog (hint provided by Jonathan, Small
Business Services) first and it proved to work "as seen on the Web".

Here are the steps I've done to get it working - it's easy, but I
couldn't find any how-to's on this so here's a mini how-to, I hope
others will be able to find it in archives when needed.

1. ZCatalog
The relevant doc for v2.6 are here
http://zope.org/Documentation/Books/ZopeBook/2_6Edition/SearchingZCatalog.stx
(I use Zope 2.5.x)
So, I found the Web docs very confusing so I just tried intuitively -
added ZCatalog, went to its Find Objects tab, catalogued all objects in
a directory/folder
Then I created a pair of forms (Search/Results) by adding ZSearch
Interface. I tried searching for *keyword* in Title, it worked.

2. Search Form 
To be able to search "*keyword*" (in title, in my case) in an easier way
(without having to enter the asterisks), you can simplify the default
search form to something like this:

<form action="categories.html" method="POST">
<p>Select files of type: 
<select name="title">
     <option value="*Category A*" selected>List Category A</option>
     <option value="*Category B*" selected>List Category B</option>
</select>
<p><input type="submit"></p>
</form>

3. Results Form
If necessary, modify the default search results form to list URLs to
files.

4. Further improvements
If you want to combine steps 2 & 3 into one page, refer to 
http://www.devshed.com/Server_Side/Zope/ZopeForm/page6.html
Instead of his <dtml-if submit>, I have <dtml-if title>, also for
the dtml-else tag.

Again, thanks to those who helped.. 

Cheers
Sean



More information about the Zope mailing list