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:

General Questions /

General questions about getting started with SilverStripe that don't fit in any of the categories above.

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

Search not working

Go to End

28 Posts   5985 Views


Community Member, 46 Posts

6 September 2011 at 5:17pm

I'm using a custom template called wine... available from the silverstripe themes gallery.

I was under the impression that the search function was already there, it just needed to be activated and to do that you had to place $SearchForm into the to make it work.


Forum Moderator, 1391 Posts

7 September 2011 at 3:22am

Edited: 12/09/2011 8:44am

I strongly advise you to follow invader_ zim's suggestion and visit the tutorial:

It tells you exactly what you need to do to get elementary site search working.

OK, as long as you enable fulltextsearch (FulltextSearchable::enable();), you don't even have to add the SearchForm() and results() methods to your Page: FullTextSearchable automatically enables the ContentControllerSearchExtension on the Page_Controller for basic search functionality and I didn't know that - shame on me :-(


Community Member, 143 Posts

11 September 2011 at 8:51am

Edited: 11/09/2011 8:52am

Sorry to hyjack, i have the EXACT same problem. I am under SS 2.4.5

Here is the URL :

I've followed the Search Tutorial and this is what it gives me (look at the URL) after i hit the results button. (More below pic).

What i did:

- add the code to the Page.php file

- create a and save it into the templates/layout/ folder

- did a dev/build. It gives me this (not sign of Result Page)

Any clue? Thanks!


Forum Moderator, 1391 Posts

12 September 2011 at 8:35am

I don't think your problem is the same at all... Looking at your site's HTML, you can see there is an actual SearchForm generated, and pressing 'go' sends you to the correct URL. Only things missing on your page are the results...

Looks to me SilverStripe hasn't found your template yet, and renders the second choice: the default Page template. You might want to do a flush=1, to refresh the template cache. Something like this:

Note: as for dev/build: it's normal you wouldn't see any references to a Page_results page, because that pagetype class doesn't exist, there is only the template


Community Member, 143 Posts

12 September 2011 at 10:27am

Hi Martimiz, tried that too. Still nothing. And i have noticed that its not using the template. I left some HTML comments in the template that i should see.

Ive erased and redid the tutorial 2 times. Still nothing.

Because the renderWith function is into PAGE.PHP

But one thing is puzzling me: the suggest content of is different depending on which tutorial/source i am using.

One is take at
and begins with:
<div id="Content" class="searchResults">

The other is at
and begins with:
<div class="typography">
<% if Results %>
<ul id="SearchResults">

Which one is the right one. I am using SS 2.4.5



Forum Moderator, 1391 Posts

12 September 2011 at 9:03pm

no, you don't need a Page_results.php page! As for the different templates: I don't know which one is the best in your situation, layout-wise, but they should both at least do something, even just ruin your layout... Anyway, I'd stick to the one in the tutorial for now...

- You should only have one (1) in your templates directory.

- Also you could put an echo of some sort in your Page_Controllers results() function to see if it ever gets there.

- Make sure there is no typo in the template name in your results() function.

- You could try empty the silverstripe-cache directory (if you're using that) to force a refresh...


Community Member, 143 Posts

13 September 2011 at 1:56pm

Edited: 13/09/2011 2:03pm

Tried all that but the "cache" thing. Afraid to break something. It seems so fragile..... Here is the set-up and tell me looks/is wrong.

I am using SS 2.4.5.

The site is at

I am willing to give FTP access, CMS access and some money to help me with that! I NEED that to work.


<form id="SearchForm_SearchForm" action="/fr/services/autofinancement/SearchForm" method="get" enctype="application/x-www-form-urlencoded">

<div id="Search" class="field text nolabel"><div class="middleColumn"><input type="text" class="text nolabel" id="SearchForm_SearchForm_Search" name="Search" value="" /></div></div>

<input class="action " id="SearchForm_SearchForm_action_results" type="submit" name="action_results" value="Go" title="Go" />


/***** FROM _CONFIG.PHP **********/



Did a /dev/build after.

/***** FROM PAGE.PHP **********/

function results($data, $form){
$data = array(
'Results' => $form->getResults(),
'Query' => $form->getSearchQuery(),
'Title' => 'Search Results'
$this->Query = $form->getSearchQuery();

return $this->customise($data)->renderWith(array('Page_results', 'Page'));



<div class="typography">
<% if Results %>
<ul id="SearchResults">
<% control Results %>
<% if MenuTitle %>
<h3><a class="searchResultHeader" href="$Link">$MenuTitle</a></h3>
<% else %>
<h3><a class="searchResultHeader" href="$Link">$Title</a></h3>
<% end_if %>
<% if Content %>
<% end_if %>
<a class="readMoreLink" href="$Link" title="Read more about &quot;{$Title}&quot;">Read more about &quot;{$Title}&quot;...</a>
<% end_control %>
<% else %>
<p>Sorry, your search query did not return any results.</p>
<% end_if %>

<% if Results.MoreThanOnePage %>
<div id="PageNumbers">
<% if Results.NotLastPage %>
<a class="next" href="$Results.NextLink" title="View the next page">Next</a>
<% end_if %>
<% if Results.NotFirstPage %>
<a class="prev" href="$Results.PrevLink" title="View the previous page">Prev</a>
<% end_if %>
<% control Results.SummaryPagination(5) %>
<% if CurrentBool %>
<% else %>
<a href="$Link" title="View page number $PageNum">$PageNum</a>
<% end_if %>
<% end_control %>

<% end_if %>


Am i missing something?

Should that returns the results?


Forum Moderator, 1391 Posts

13 September 2011 at 10:28pm

We've all been there at some point, I guess... :-(

First of all: afaik you can definitely empty the silverstripe-cache directory, no problem, no instability, as long as it's writable, it will rebuild itself automatically.

Now - I see your site definitely responding to your search request - just not the way you want it to... Go to your url, then copy the underlying html. Then perform a search on that page, and you'll see your gallery going out of bounds. Copy that html and see if you recognize the different templates being used...