Jump to:

23480 Posts in 18951 Topics by 2878 members

General Questions

SilverStripe Forums » General Questions » is the search TUTORIAL correct?

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

Page: 1
Go to End
Author Topic: 416 Views
  • Richi
    Community Member
    16 Posts

    is the search TUTORIAL correct? Link to this post

    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. mydomain.com/home/results 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 Page_results.ss 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!

  • Willr
    Forum Moderator
    5502 Posts

    Re: is the search TUTORIAL correct? Link to this post

    If you have SS2.4 then you don't need the tutorial - it's built in http://doc.silverstripe.org/sapphire/en/tutorials/4-site-search#2-4-and-newer

  • Richi
    Community Member
    16 Posts

    Re: is the search TUTORIAL correct? Link to this post

    Yes, I do use SS 2.4.
    Do you mean, I don't have to build the Page_results.ss, 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!

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.