Jump to:

2002 Posts in 1422 Topics by 616 members

Form Questions

SilverStripe Forums » Form Questions » Search form includes error pages

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

Page: 1
Go to End
Author Topic: 427 Views
  • Puddle
    Avatar
    Community Member
    2 Posts

    Search form includes error pages Link to this post

    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.

  • Puddle
    Avatar
    Community Member
    2 Posts

    Re: Search form includes error pages Link to this post

    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);
          }
       }

    427 Views
Page: 1
Go to Top

Want to know more about the company that brought you SilverStripe? Then check out SilverStripe.com

Comments on this website? Please give feedback.