Jump to:

17452 Posts in 4473 Topics by 1971 members

Archive

SilverStripe Forums » Archive » 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: 1221 Views
  • corkg
    Avatar
    Community Member
    30 Posts

    Search Link to this post

    How can I restrict the search to only level 2 and 3 pages like the Menu(2), so if

    Home
    ---Food
    ------Food1
    ---Special Food
    ------Food 1
    ------Food 2
    About Food

    it would only show

    ---Food
    ------Food1
    ---Special Food
    ------Food 1
    ------Food 2

  • simon_w
    Avatar
    Forum Moderator
    471 Posts

    Re: Search Link to this post

    In the CMS, you can make a page not show up in searches.

    Alternatively, you could create a subclass of SearchForm, where you override searchEngine() to something like:

    public function searchEngine($keywords, $numPerPage = 10, $sortBy = "Relevance DESC", $extraFilter = "", $booleanSearch = false, $alternativeFileFilter = "", $invertedMatch = false) {
    return parent::searchEngine($keywords, $numPerPage, $sortBy, "SiteTree.ParentID = 0", $booleanSearch, $alternativeFileFilter, $invertedMatch);
    }


    Then use that class instead of SearchForm.

  • corkg
    Avatar
    Community Member
    30 Posts

    Re: Search Link to this post

    thanks

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