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've moved the forum!

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.

Form Questions /

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

Search form includes error pages


Go to End


2 Posts   1179 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);
}
}