Am wondering how I would go about increasing the amount of search results from the default 10?
Cheers!
This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.
Please use forum.silverstripe.org for any new questions
(announcement).
The forum archive will stick around, but will be read only.
You can also use our Slack channel
or StackOverflow to ask for help.
Check out our community overview for more options to contribute.
Am wondering how I would go about increasing the amount of search results from the default 10?
Cheers!
Mate, you need to post your code here, and be more specific, so people here can understand your problems better.
Assuming you are using the following:
/**
* Site search form
*/
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);
}
/**
* Process and render search results
*/
function results($data, $form){
$data = array(
'Results' => $form->getResults(),
'Query' => $form->getSearchQuery(),
'Title' => 'Search Results'
);
return $this->customise($data)->renderWith(array('Page_results', 'Page'));
}
then in the function results() modify the second line like following:
function results($data, $form){
$data = array(
'Results' => $form->getResults(20), //add the number of search results as param
'Query' => $form->getSearchQuery(),
'Title' => 'Search Results'
);
return $this->customise($data)->renderWith(array('Page_results', 'Page'));
}
Thanks Ben - perfect.
Apologies, I completely forgot to post the code but I was using the standard Silverstripe tutorial stuff.