I would like to add a feature to the core string contextual filter, implemented in core/modules/views/src/Plugin/views/argument/StringArgument.php.
If I use hook_views_query_alter()
, I would have to undo everything the core function did first, then roll out my changes.
Is there a way to just completely override the core function instead of only altering the results?
The contextual range filter accomplishes this by presenting the site admin with a configuration page to select which instances of an existing filter should be replaced by the new object. I could follow this route, but I would prefer to update all cases site-wide.
NumericArgument
andStringArgument
toNid
andType
. So if you want to override contextual filters for content globally, you have to override these plugins and replace them in hook_views_data_alter().@ViewsArgument("string_operator")
, I imagine I would have to have an install script run hook_views_data_alter to do something like$current = $data[$table_name][$field_name]['argument']['id']; if ($current == 'string') $data[$table_name][$field_name]['argument']['id'] = 'string_operator';
. Then how do I let drupal know that my new argument is the default to use for all future string fields?Drupal\views\Plugin\views\argument\StringArgument.php = @ViewsArgument("string")
toDrupal\views\Plugin\views\argument\StringArgument.php = @ViewsArgument("string_old")