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, biapar, Willr, Ingo, simon_w

add new CMS fields to search


Reply


3 Posts   1808 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 [url=http://doc.silverstripe.com/doku.php?id=tutorial:4-site-search]search[/url] 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.