Jump to:

17452 Posts in 4473 Topics by 1971 members

Archive

SilverStripe Forums » Archive » add new CMS fields to search

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

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

Page: 1
Go to End
Author Topic: 1805 Views
  • Anatol
    Avatar
    126 Posts

    add new CMS fields to search Link to this post

    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

  • sybalos
    Avatar
    Community Member
    4 Posts

    Re: add new CMS fields to search Link to this post

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

  • dio5
    Avatar
    Community Member
    501 Posts

    Re: add new CMS fields to search Link to this post

    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.

    1805 Views
Page: 1
Go to Top

Want to know more about the company that brought you SilverStripe? Then check out SilverStripe.com

Comments on this website? Please give feedback.