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.

Form Questions /

site search template/classname in 2.4


Reply


1286 Views

Avatar
jenniferaslan

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 [url=http://www.silverstripe.org/customising-the-cms/show/6243]thread[/url] 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?