Jump to:

1999 Posts in 1421 Topics by 613 members

Form Questions

SilverStripe Forums » Form Questions » site search template/classname in 2.4

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

Page: 1
Go to End
Author Topic: 1175 Views
  • jenniferaslan
    Avatar
    Community Member
    5 Posts

    site search template/classname in 2.4 Link to this post

    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?

    1175 Views
Page: 1
Go to Top

Want to know more about the company that brought you SilverStripe? Then check out SilverStripe.com

Comments on this website? Please give feedback.