5102 Posts in 1520 Topics by 1116 members
|
Page:
1
|
Go to End | |
| Author | Topic: | 889 Views |
-
Increase amount of search results

9 May 2011 at 5:57pm
Am wondering how I would go about increasing the amount of search results from the default 10?
Cheers!
-
Re: Increase amount of search results

10 May 2011 at 12:01pm
Mate, you need to post your code here, and be more specific, so people here can understand your problems better.
-
Re: Increase amount of search results

10 May 2011 at 12:12pm
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'));
} -
Re: Increase amount of search results

10 May 2011 at 2:50pm
Thanks Ben - perfect.
Apologies, I completely forgot to post the code but I was using the standard Silverstripe tutorial stuff.
| 889 Views | ||
|
Page:
1
|
Go to Top |

