Hi,
maybe this has been asked a lot of times but I don't get it running...
I want to add some additional fields of my SiteTree object to be available for fulltext search (the one in the front-end)
So in my Page.php if have
class Page extends SiteTree {
static $db = array(
'Teaser' => 'Text',
'TinyURL' => 'Varchar(255)'
);
static $searchable_fields = array (
'Teaser' => array(
'field' => 'TextField',
'filter' => 'PartialMatchFilter',
'title' => 'Teaser Text'
),
);
....
}
No i entered some text in the Teaser field in the backend and expected the page to be found using the frontend-search.
AR: wasn't found...
Did i miss something?
I use the default search implementation in the Page_Controler:
public function SearchForm() {
$searchText = isset($_REQUEST['Search']) ? $_REQUEST['Search'] : 'Search';
$fields = new FieldSet(
new TextField("Search", "", $searchText)
);
$actions = new FieldSet(
new FormAction('results', 'Search')
);
return new SearchForm($this, "SearchForm", $fields, $actions);
}
public function results($data, $form) {
$form->classesToSearch(array(
'SiteTree',
//'File',
));
$results = $form->getResults();
$results->removeDuplicates('ID');
$data = array(
'Result' => $results,
'Query' => $form->getSearchQuery(),
'Title' => 'Search Results'
);
return $this->customise($data)->renderWith(array('Article_proc', 'Page'));
}