Ticket #2279 (new patch)

Opened 11 months ago

Last modified 4 months ago

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.

Attachments

search-custom-fields.patch (5.2 kB) - added by mpeel 11 months ago.

Change History

Changed 11 months ago by mpeel

Changed 11 months ago by mpeel

Also, I should add that I'm not that up to the play with the SearchForm?, so this code can probably be refactored into a much more elegant solution pretty easily... but it's after 3am and this is at least a start.

Changed 10 months ago by ischommer

fyi, i've added a $searchable_fields static to Member.php (to be generalized into DataObject?.php), which could be a starting point for any work on this issue.

Changed 6 months ago by sminnee

  • owner changed from sminnee to ischommer

Ingo/Matt, has any progress on this?

Changed 4 months ago by ischommer

  • milestone 2.2.3 deleted

This could be changed/invalidated by our recent work on SearchContext?. As the querying and search concepts are in a bit of a unknown state at the moment, I'd suggest we leave this patch until the new datamapper und SearchContext? are implemented.

Note: See TracTickets for help on using tickets.