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:

Form Questions /

Moderators: martimiz, Sean, Ed, biapar, Willr, Ingo, swaiba

site search template/classname in 2.4


Go to End


1649 Views

Avatar
masterys

Community Member, 5 Posts

6 January 2011 at 11:37am

I am building a site in 2.4.4 and have enabled the search box with the following in my _config.php file:

FulltextSearchable::enable();

I have created two page types that extend SiteTree: Page and HomePage. When I submit the search form from the home page, the search results display in the HomePage.ss template, using the Page_results.ss layout and when I submit the form from an interior page, the search results display in the Page.ss template, using the Page_results.ss layout. This is not good because the HomePage and Page templates don't really have anything in common and that's why they are separate and both just extend SiteTree. I want the search results to always use the Page.ss template and the Page_results.ss layout, whether I submit the search form from the home page or an interior page.

I had found another thread in this forum that suggests adding a line to the function results() in your Page.php file like this:

'ClassName' => 'Page_results' 

The problem is that in this version of SilverStripe, the function for the search results is built into the core and isn't in Page.php anymore. How can I specify the template that I always want the search results to use?