-
-
Notifications
You must be signed in to change notification settings - Fork 353
Creating a Search Provider Component
The Rock Framework has a pretty easy way to hook new "search providers" into the main search window. Here are the high level steps:
- Create a class inherits from
Rock.Search.SearchComponent
which implements the Search method that takes a search string and returns any matching results in anIQuerable<string>
. - Create a search results block that handles displaying the results list when multiple matches are found or redirects to an appropriate 'view item' page (using the friendly route name) when only one item was found.
- If one does not yet exist, add a route to a your page with this block (e.g. "Person/Search/{SearchType}/{SearchTerm}")
- If one does not yet exist, add a route to a page that can view the item (e.g. "Person/{personId}")
When you add a new search component in your environment, Rock will automatically detect it and list it on the Search Services page (Administration->System Settings->Search Services) For now, it's in there where you will need to specify the Result URL route (e.g. such as Person/Search/name/{0}
) and the Search Label. The Search Label will be displayed in the search box as a drop down option. Later on, if you're going to ship your component, you'll probably want to create a migration for it using the steps below.
If you're creating a migration for a new search provider component, you will probably want to:
- Add the new component as a new Entity
- Add the appropriate attributes (Result URL, Search Label, Active, and Order)
- Add the appropriate default attributes values
- The Result URL value should be a route that includes the identifier as the
{0}
as in `"Person/Search/name/{0}" - The Active value should be
"True"
otherwise it won't be activated in the system.
- The Result URL value should be a route that includes the identifier as the
- Add your new BlockType, add a new search results page, and add an instance of your block to that page.
- Add a route to your search results page (e.g.
Person/Search/name/{0}
).
Prior to the v0.9 release you can see an example migration in 201307312305307_GroupSearchComponent.cs