Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

Data Model Questions /

Quick search with extra fields (per page-type)? Is it possible?


Reply


492 Views

Avatar
Friksel

Community Member, 7 Posts

19 December 2012 at 10:32pm

Edited: 19/12/2012 10:48pm

In the CMS we use different DataObject-Types and custom PageTypes, all with there own relations and datafields.
Now I want to use the quick site-search option of Silverstripe 3.0.3. That works exactly like I expect, but it only searches in the fields Title, MetaTitle, MetaDescription and Content.

I want to expand this functionality so that it also searches through other fields and dataobjects used as relations in those pages. I was hoping that it just as easy as filling in the static $searchable_fields array with the extra fields to search in, but that doesn't work.

Here is how I enter the searchfield 'Introduction' (Text) as a searchable field:

static $searchable_fields = array(
'Introduction'
);

Am I doing something wrong here? I don't understand the meaning of $searchable_fields if it doesn't search those fields.

So how can I create a general quick search that works on every page and returns the result of all pages, searched not only in the default fields, but also in (for each pagetype different) extra fields? I tried a lot and was reading my way through some Silverstripe docs about searching, but somehow it either doesn't work for my needs or I don't get the systematics of it.

Hope you guys can help!!