[Zope] Searching and only one result.
Peter Bengtsson
mail@peterbe.com
Tue, 10 Jul 2001 16:11:12 +0200
A silly but working solution is this:
[i do it in python script to save typing. You can do this in cluttered DTML
or ZPT if you want, later]
"""
Will return a dictionary like this:
{'Annie':3,'Albert':2}
"""
res={}
for name in catalogsearcresult('A'):
if res.has_key(name):
res[name] = res[name]+1
else:
res[name]=1
return res
"""
This can be looped over like this:
for key, value in res.items():
print "<li>%s has %s articles</li>" % (key, value)
"""
I.e. you have to prepare and analys the search results a bit first.
There are two loops here, but the second one is very simple and fast.
Cheers, Peter
----- Original Message -----
From: "James van der Veen" <james@codenamefuture.nl>
To: <zope@zope.org>
Sent: Tuesday, July 10, 2001 3:46 PM
Subject: [Zope] Searching and only one result.
Hi everyone,
I have Made a ZClass where people can add news itemīs to the site.
Now I added a property to the catalog when they add the news item that gets
the first letter of the person who wrote the article.
Now I have a search page where people can search for articles on the name of
the one who wrote the article.
But now the results show the same name twice if one person has written
multiple articles. How can I make sure the results will only show the name
of this peron once?
for instance: Albert wrote 2 articles and Annie 3
a person on the site searches for the A.
Now it will give
Annie
Annie
Annie
Albert
Albert
But the thing I want to do is that it will do this:
Annie (3) click here to see all annies ........
Albert (2) click.........
Can any of you help me with this?
Sure hope so!!
James
_______________________________________________
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 )