Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

We're retiring the forums!

The SilverStripe forums have passed their heyday. They'll stick around, but will be read only. We'd encourage you to get involved in the community via the following channels instead:

Form Questions /

Moderators: martimiz, Sean, Ed, biapar, Willr, Ingo, swaiba

Search form includes error pages


Go to End


2 Posts   911 Views

Avatar
Puddle

Community Member, 2 Posts

14 March 2013 at 3:21am

Downloaded the latest SS. Great system and highly flexible. I haven't ran in to any problems uptil now: I implemented a search form, but when I start an empty search it includes everything (including error pages, images etc). Now I filtered out the empties using ContentControllerSearchExtension and filtering "if(!emty($data[Query]))" etc etc. That works, although the "return" statement in the "else" fails.

Anyway: can someone please help me? Unchecking 'Show in search' also does not work.

Avatar
Puddle

Community Member, 2 Posts

14 March 2013 at 3:53am

Temporary workaround (nasty I know, but it works)

public function results($data, $form, $request) {
$data = array(
'Results' => $form->getResults(),
'Query' => $form->getSearchQuery(),
'Title' => _t('SearchForm.SearchResults', 'Search Results')
);
$searchLength = strlen($data[Query]);
if($searchLength > 2){
return $this->owner->customise($data)->renderWith(array('Page_results', 'Page'));
} else {
return $this->owner->customise($data);
}
}