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.

We've moved the forum!

Please use forum.silverstripe.org for any new questions (announcement).
The forum archive will stick around, but will be read only.

You can also use our Slack channel or StackOverflow to ask for help.
Check out our community overview for more options to contribute.

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   2313 Views

Avatar
Anatol

126 Posts

6 December 2007 at 12:37pm

Edited: 06/12/2007 3:10pm

Hi,

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).

Cheers!
Anatol

Avatar
sybalos

Community Member, 4 Posts

3 March 2008 at 11:30am

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

Avatar
dio5

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.