Version: current

     1 <?php
     2 /**
     3  * Виджет "Форма поиска по сайту"
     4  * Позволяет разместить в боковой колонке форму поиска по сайту
     5  *
     6  * @package widgets
     7  * @author  menedem
     8  */
     9 class SearchWidget extends SidebarWidget {
    10
    11     function SearchForm($extra='widget') {
    12         $controller = Controller::curr();
    13         if ($controller && $controller->hasMethod('SiteSearchForm')) {
    14             return $controller->SiteSearchForm($extra);
    15         }
    16
    17         $searchText = isset($_REQUEST['Search']) ? $_REQUEST['Search'] : '';
    18         $fields = new FieldSet(
    19             new TextField("Search", "", $searchText)
    20         );
    21         $actions = new FieldSet(
    22             new FormAction('results', _t('Webylon.SEARCH', 'Search'))
    23         );
    24
    25         return new SearchForm(new Search_Controller(), "SearchForm", $fields, $actions);
    26     }
    27
    28     function getCMSFields(){
    29         $fields = parent::getCMSFields();
    30         $fields->removeByName('ClassName');
    31         return $fields;
    32     }
    33
    34     function hasContent() {
    35         return true;
    36     }
    37 }

[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. -