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

is the search TUTORIAL correct?


3 Posts   461 Views


Community Member, 16 Posts

9 November 2011 at 5:18am

Edited: 09/11/2011 5:19am

Hey there,
the search tutorial seems to be simple, but I must be missing out something.
I'm asking because I keep getting a fatal error when I try to open e.g. and the search itself does not work at all.

I did all what the tutorial told me to do, function results in page.php, created the and FulltextSearchable::enable(); in my config.

Fatal error: Call to a member function getResults() on a non-object in .../mysite/code/Page.php on line 22


class Page extends SiteTree {

   public static $db = array(
    'Sidecontent' => 'HTMLText'

   public static $has_one = array(
   function getCMSFields() {
$fields = parent::getCMSFields();
$fields->addFieldToTab("Root.Content.Sidecontent", new HTMLEditorField('Sidecontent','Sidecontent Content'));
return $fields;

class Page_Controller extends ContentController {
   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'));

    * An array of actions that can be accessed via a request. Each array element should be an action name, and the
    * permissions or conditions required to allow the user to access it.
    * <code>
    * array (
    * 'action', // anyone can access this action
    * 'action' => true, // same as above
    * 'action' => 'ADMIN', // you must have ADMIN permissions to access this action
    * 'action' => '->checkAction' // you can only access this action if $this->checkAction() returns true
    * );
    * </code>
    * @var array
   public static $allowed_actions = array (

   public function init() {

      // Note: you should use SS template require tags inside your templates
      // instead of putting Requirements calls here. However these are
      // included so that our older themes still work

Would be nice if someone could help me out here. Thank you!


Forum Moderator, 5513 Posts

10 November 2011 at 9:02pm

If you have SS2.4 then you don't need the tutorial - it's built in


Community Member, 16 Posts

10 November 2011 at 9:19pm

Yes, I do use SS 2.4.
Do you mean, I don't have to build the, nor do I have to alter my page.php, if I use 2.4?
Testing this right now, this wasnt clear to me.

Thank you Willr!