Custom Drupal module with utilities for repetitive operations
- Add the following snippet to the
repositories
section of yourcomposer.json
file:
{
"type": "git",
"url": "https://github.com/eaudeweb/edw_utilities.git"
}
-
Run
composer require eaudeweb/edw_utilities:^1.0
-
Enable the module:
drush en edw_edw_utilities
Location: modules/edw_utilities/src/Plugin/search_api/processor/FieldValueIndex.php
Location: modules/edw_utilities/src/Controller/TermsAutocompleteController.php
You can alter autocomplete results with hook_terms_autocomplete_query_alter
Attach the autocomplete:
function hook_form_views_exposed_form_alter(array &$form, FormStateInterface &$form_state) {
switch ($form['#id']) {
case 'views-exposed-form-ID':
$form['text']['#autocomplete_route_name'] = 'edw_utilities.terms_autocomplete';
$form['text']['#autocomplete_route_parameters'] = [
'vid' => 'YOUR_TAXONOMY_TERM_BUNDLE',
];
break;
}
}
Location: modules/edw_utilities/src/Plugin/views/argument_default/EntityBrowserWidgetContextNode.php