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.

Form Questions /

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

site search template/classname in 2.4


Go to End


2098 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?