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.

Archive /

Our old forums are still available as a read-only archive.

Moderators: martimiz, Sean, Ed, biapar, Willr, Ingo

add new CMS fields to search

Go to End

3 Posts   2161 Views


126 Posts

6 December 2007 at 12:37pm

Edited: 06/12/2007 3:10pm


Is it possible to add a new field in the CMS (by overloading getCMSFields()) to the search?
E.g. I created a new field ContentMore:

$fields->addFieldToTab("Root.Content.Main", new HtmlEditorField("ContentMore", "More", 10));

but it seems the default Silverstripe search searches only in the "Content" field (or maybe the standard fields).



Community Member, 4 Posts

3 March 2008 at 11:30am

I'm interest in knowing how too! Any solution ?


Community Member, 501 Posts

3 March 2008 at 12:09pm

Yes, this is possible, but not really evident.

You have to either extend the SearchForm class ( sapphire/search/SearchForm.php) or modify the file itself.

Basically you'll have to add the fields to the $queryContent->select of the searchengine method, but be carefull you don't make it crash on it, as your custom fields probably won't be available on every page.