Adding search to your module By Matthew McNaney ---------------------------------------------------- Introduction ------------------------------------------------------------------- Adding search to your mod is really simple. All that is required is usage of the Key class. If your module isn't using Key, then you will need to build in your own search capabilities. The search object ------------------------------------------------------------------- To begin, you need to create a search object: $search = & new Search($key_id); The key_id variable is the id to the key indexed to your content item. Next you need to filter some content through the search object. The search object will attempt to filter out search keywords. $search->addKeywords($content); You could also add your element's title, location, address, etc. just by calling addKeywords again: $search->addKeywords($title); Once you are finished filtering keywords, just save the search object. $search->save(); The result of the save function will either be true or an error object. If you are updating an item make sure to reset the keywords before adding any new ones. $search->resetKeywords(); $search->addKeywords('dog'); $search->addKeywords('cat'); Search will pull your current information when you initialize it. If you don't reset your keywords, you will be adding on to the previous list. If you removed a search word from your content it will be included with the others. So if you had 'dinosaur' from a previous save, removed it, and didn't reset, then that item will still appear when 'dinosaur' is searched for.