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're retiring the forums!

The SilverStripe forums have passed their heyday. They'll stick around, but will be read only. We'd encourage you to get involved in the community via the following channels instead:

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   1540 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