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
Page.php
<?php
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() {
parent::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
Requirements::themedCSS('layout');
Requirements::themedCSS('typography');
Requirements::themedCSS('form');
}
}
Would be nice if someone could help me out here. Thank you!