DMTL-IF: Listing Documents that contain queryword
I manually set Document Properties for files that I want to list in groups. Each Document has a Property "category"; to get Category One docs, I use <dtml-in "my_documents.objectValues()"> <dtml-if "category=='Category One'"> <dtml-comment>List Documents</dtml-comment> </dtml-if> </dtml-in> Since Documents already have the word I need in dtml-var Title (Category One: Whatever Title), I'd like to use a Web form to pass the query string and get rid of having to manually set Properties for each Document. I'd like to list any Document that contains string "query", like: "select Documents where <dtml-var title> like queryword" Can someone help me with this? If possible, I'd like to accomplish this in Zope without external scripts programming languages. Env: Zope 2.5.x, Python 2.2.x Thanks Sean
On Sat, 2003-11-22 at 10:13, Sean Lee wrote:
Since Documents already have the word I need in dtml-var Title (Category One: Whatever Title), I'd like to use a Web form to pass the query string and get rid of having to manually set Properties for each Document. I'd like to list any Document that contains string "query", like: "select Documents where <dtml-var title> like queryword"
Here's a Python Script that assumes that the string you get passed in can be found at the *beginning* of the title and the querystring variable is called "category": ---- docs = context.objectValues(object_type) target_len = len(category) collector = [] for doc in docs: if doc.title[:target_len] == category: collector.append(doc) return collector ---- HTH, Dylan
participants (2)
-
Dylan Reinhardt -
Sean Lee