Ticket #2279 (new patch)
PATCH (Needs Review): Ability to specify custom search fields for individual SearchForm instances
| Reported by: | mpeel | Owned by: | ischommer |
|---|---|---|---|
| Priority: | medium | Milestone: | |
| Component: | Sapphire Framework | Version: | 2.2.1 |
| Severity: | medium effort / impact | Keywords: | |
| Cc: | Hours: |
Description
This is a patch that allows you to specify extra fields on sub-classes on SiteTree? to be searched on.
You do this by doing something like this:
$form = new SearchForm($this, "SearchForm", $fields, $actions); $form->addCustomFields(array( "SiteTree" => array( "Page" => array( "HeaderTitle" => "HeaderTitle", "HeaderContent" => "HeaderContent" ), ), )); return $form;
To make it also search inside the HeaderTitle? and HeaderContent? fields on the Page (or Page_Live, depending on your versioning stage) table.
Note: This .patch has been created from the 2.2.1-dnc branch of sapphire, NOT trunk. At the time of creating the patch, 2.2.1-dnc was at revision r50229.
This patch needs review before being committed back into trunk, and a more generic solution might be nicer (aka. being able to search any DataObject?, instead of assuming that 'SiteTree?' or 'File' is the base class - this hasn't been tested).
Another thing that hasn't been fully tested in searching under different languages. Particularly, after a quick test I found that if I searched in a language other than the default, I wasn't able to find words written in that language in the custom search fields.
