source: trunk/skins/toolbox/find_related_stories.py @ 53

Revision 53, 816 bytes checked in by meelis, 14 years ago (diff)

renaming activities to stories

Line 
1## Script (Python) "find_related_stories.py"
2##bind container=container
3##bind context=context
4##bind namespace=
5##bind script=script
6##bind subpath=traverse_subpath
7##parameters=
8##title=Finds all related stories
9from Products.CMFCore.utils import getToolByName
10keywords = context.Subject()
11if not keywords:
12    return []
13keys = ''
14for key in keywords:
15    keys=keys+key+' or '
16keys = keys[:-4]
17query_string = {'SearchableText': {'operator': 'or', 'query': keys},
18    'sort_on' : 'Date', 'sort_order' : 'descending', 'meta_type' : {'query' : 'Story'}}
19pcatalog = getToolByName(context, 'portal_catalog')
20tmp_results = pcatalog.searchResults(query_string)
21results = []
22for x in tmp_results:
23    if x.getURL() == context.absolute_url():
24        continue
25    results.append(x)
26return results
Note: See TracBrowser for help on using the repository browser.