1 <?php
2 3 4 5 6 7
8 class ContentControllerSearchExtension extends Extension {
9 static $allowed_actions = array(
10 'SearchForm',
11 'results',
12 );
13
14 15 16
17 function SearchForm() {
18 $searchText = isset($_REQUEST['Search']) ? $_REQUEST['Search'] : 'Search';
19 $fields = new FieldSet(
20 new TextField('Search', '', $searchText)
21 );
22 $actions = new FieldSet(
23 new FormAction('results', 'Search')
24 );
25 return new SearchForm($this->owner, 'SearchForm', $fields, $actions);
26 }
27
28 29 30 31 32 33 34
35 function results($data, $form, $request) {
36 $data = array(
37 'Results' => $form->getResults(),
38 'Query' => $form->getSearchQuery(),
39 'Title' => 'Search Results'
40 );
41 return $this->owner->customise($data)->renderWith(array('Page_results', 'Page'));
42 }
43 }
[Raise a SilverStripe Framework issue/bug](https://github.com/silverstripe/silverstripe-framework/issues/new)
- [Raise a SilverStripe CMS issue/bug](https://github.com/silverstripe/silverstripe-cms/issues/new)
- Please use the
Silverstripe Forums to ask development related questions.
-