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.

General Questions

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

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

Search not working


28 Posts   3624 Views


14 September 2011 at 2:52pm (Last edited: 14 September 2011 3:18pm), Community Member, 142 Posts

It works!

Solution taken: move out of /Layout and back into /Templates

Had to rewrite the whole to include all those #divs, but its works.

Will also have to restyle everything.

One questions:

1) Is there any harm moving Page_results out of /Layout?? Id wouldnt think so.

- - -

Ill sleep better!



14 September 2011 at 10:41pm Forum Moderator, 1091 Posts

OK, that's it then. And yes, you can remove from Layout. As for the why: Layout is used to make it possiblee to create a wrapper template /templates/ for all pagetypes that are styled alike. Then, where the contents that are different for each pagetype should be, you put $Layout.

Next in your /template/Layout directory you can put template blocks for your different pagetypes in,, SilverStripe automatically include the appropriate part from the Layout directory.

If you have a pagetype like HomePage that should be styled completely different, you just place it in /templates/, and skip the $Layout part. And that's what you're doing for all your pages at the moment...

Advice: take a look at the SilverStripe tutorials and help, where these things are explained, now the pressure's off :-)


18 September 2011 at 7:45pm (Last edited: 18 September 2011 7:45pm), Community Member, 46 Posts

Ok... I have done the following and still search is not working:

Firslty I have added $SearchForm to the file in mysite/themes/wine/templates/

The file now looks like this:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "">
<html xmlns="">

      <% base_tag %>
      <link rel="shortcut icon" href="/favicon.ico" />

<div id="Wrapper">
   <div id="Header">
    <h1><span>Christina French</h1>
<p class="tagline">Artist & Tutor</p>
<input type="text" class="search" value="Search" />
<div id="Nav">
   <% include Navigation %>

<div class="clear"></div>

<div id="Footer">
   <% include Footer %>



Secondly I have added FulltextSearchable::enable(); to the _config.php file in mysite/_config.php

The file now looks like this:




I have run a dev/build and when the page refreshed there was nothing that looked like it had changed. could this be something to do with the template i'm using... If so should I look at some of the other search tutorials??


19 September 2011 at 2:00am Forum Moderator, 1091 Posts

No, unless you're referring to some other site now, your code still shows only a single searchfield, that isn't part of a form, so it cannot work. Some questions:

- did you create a function SearchForm() in your Page_Controller? What does it say?

- did you create a function results() in your Page_Controller? What does it say?

- do you by any chance have a template hanging around somewhere in your mysite or your (wine) theme directory or anywhere else you can think of besides the saphhire/cms directory?