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


Reply

28 Posts   3624 Views

Avatar
wilsonStaff

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

It works!

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

Had to rewrite the whole Page_results.ss 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!

Thanks!

Avatar
martimiz

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

OK, that's it then. And yes, you can remove Page-results.ss from Layout. As for the why: Layout is used to make it possiblee to create a wrapper template /templates/Page.ss 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 Page.ss, GalleryPage.ss, SomeOtherPageType.ss. 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/HomePage.ss, 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 :-)

Avatar
bettsaj

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 page.ss file in mysite/themes/wine/templates/page.ss

The file now looks like this:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>

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

</head>
<body>
$SearchForm
<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>
<div id="Nav">
   <% include Navigation %>
</div>

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

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

</div>

</body>
</html>

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

The file now looks like this:

<?php

FulltextSearchable::enable();
LeftAndMain::require_javascript('userforms/javascript/FieldEditor.js');
LeftAndMain::require_css('userforms/css/FieldEditor.css');

?>

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

Avatar
martimiz

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 SearchForm.ss template hanging around somewhere in your mysite or your (wine) theme directory or anywhere else you can think of besides the saphhire/cms directory?