function _search_by_page_view in Search by Page 8
Same name and namespace in other branches
- 6 search_by_page.module \_search_by_page_view()
- 7 search_by_page.module \_search_by_page_view()
Returns a ready-to-render search form and/or results page.
Parameters
$envstring: The environment ID, with 'env' prepended, to avoid argument substitution in hook_menu().
1 string reference to '_search_by_page_view'
- search_by_page_menu in ./
search_by_page.module - Implements hook_menu().
File
- ./
search_by_page.module, line 910 - Main module file for Drupal module Search by Page.
Code
function _search_by_page_view($envstring) {
$environment = intval(mb_substr($envstring, 3));
// This pretty much follows search_view()
$path = explode('/', $_GET['q'], 2);
$keys = '';
if (count($path) > 1) {
$keys = trim($path[1]);
}
$build = [];
// Display a search form
$build['search_form'] = $form = \Drupal::formBuilder()
->getForm('search_by_page_form', $environment, $keys, FALSE);
// Get search results and display them.
$path = search_by_page_setting_get('page_path', $environment, 'search_pages');
if ($keys) {
\Drupal::logger('search_by_page')
->notice(':keys', [
':keys' => $keys,
], l(t('results'), $path . '/' . $keys));
$keys = search_expression_insert($keys, 'environment', $environment);
$results = search_data($keys, 'search_by_page');
$build['search_results'] = $results;
}
return $build;
}