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

Search


Go to End


3 Posts   1601 Views

Avatar
corkg

Community Member, 30 Posts

5 July 2008 at 7:45am

Edited: 05/07/2008 7:46am

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

Avatar
(deleted)

Community Member, 473 Posts

5 July 2008 at 8:26am

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.

Avatar
corkg

Community Member, 30 Posts

5 July 2008 at 8:29am

thanks