PHP code example of silverstripers / elemental-search
1. Go to this page and download the library: Download silverstripers/elemental-search library. Choose the download type require. 2. Extract the ZIP file and open the index.php. 3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
silverstripers / elemental-search example snippets
use SilverStripe\CMS\Search\SearchForm;
class MyController extends Controller {
public function SearchForm()
{
return SearchForm::create($this, 'SearchForm');
}
public function results($data, $form, $request)
{
$data = array(
'Results' => $form->getResults(),
'Query' => DBField::create_field('Text', $form->getSearchQuery()),
'Title' => _t('SilverStripe\\CMS\\Search\\SearchForm.SearchResults', 'Search Results')
);
return $this->owner->customise($data)->renderWith(array('Page_results', 'Page'));
}
}