LiveSearchWidget
Category: Fields and widgets
—
Other products by this author
Current release: LiveSearchWidget 1.1.2
Released Sep 10, 2007 — tested with Plone 3.0, Plone 2.5
fix for plone 3
Experimental releases
Upcoming and alpha/beta/candidate releases
- Alpha releases should only be used for testing and development.
- Beta releases and Release Candidates are normally released for production testing, but should not be used on mission-critical sites.
- Always install on a separate test server first, and make sure you have proper backups before installing.
Project Description
- Project resources
This product contains The LiveSearchWidget
(see: http://www.goldmund-wyldebeast-wunderliebe.com/products)
Contents
--------
1.0 Introduction
.1 Prerequisites
.2 License
2.0 Installation
3.0 Known limitations
4.0 Example code
1.0 Introduction
----------------
The LiveSearchWidget is a widget that can be used for a referencefield.
This widget (in edit mode) will let you search for objects in a livesearch
way that is very similar to the plone livesearch functionality.
The search is performed using a standard catalog search, on the index
"SearchableText".
This widget was put together using exising code from plone's livesearch
together with a little bit from ATReferenceBrowserWidget code. By copying
the plone livesearch stuff, we think this widget will be quite solid on most
modern browsers.
With the new KSS framework in plone3 this widget (or at least the code) will
probably be deprecated. In the near future I will look into KSS in more detail
and then I will see how I will be using that in combination with this widget.
1.1 Prerequisites
-----------------
* Plone 2.5.x / 3.0
* InstallUtils (http://www.goldmund-wyldebeast-wunderliebe.com/products)
* Archetypes
* ATReferenceBrowserWidget
1.2 License
-----------
This product is distributed under the GPL license (see LICENSE.GPL)
The code that was copied and slightly modified from plone (livesearch)
is also redistributed under this GPL license
The code that was copied and slightly modified from ATReferenceBroswerWidget
is also redistributed under this GPL license
2.0 Installation
----------------
Install the product using the quick_installer.
3.0 Known limitations
---------------------
* field needs to be a referencefield
* field needs allowed_types property with only 1 element
(e.g. allowed_types=('Document',) )
NOTE: Make sure that it's really a tuple, and not just a string!!
WRONG: allowed_types=('Document')
GOOD: allowed_types=('Document',)
* vocabulary not supported. This is something that needs some work. Suggestions
are more than welcome
workaround:
you can specify a 'extra_search_args' attribute in the widget, which can be a
method that returns a map of extra arguments (see example below)
4.0 Example code
----------------
This is a snippet which shows you how to use the LiveSearchWidget
It's quite straightforward as you can see:
*** snip ***
from Products.LiveSearchWidget.widgets.livesearchwidget import *
def getExtraArgs(self):
""" return extra livesearch arguments """
# search only one level underneath current object
return {'path' : {'query' : '/'.join(self.getPhysicalPath()),
'depth' : 1,
}
}
schema = ProfileSchema.copy() + Schema((
ReferenceField('subscriptions_sms',
allowed_types=('Social Plan',),
relationship=SUBSCRIPTION_RELATION_SMS,
widget=LiveSearchWidget(label='Subscription SMS',
extra_search_args='getExtraArgs',)
),
))
*** snap ***