When working with views filters, the admin can specify if the database query is equal to, contains, starts with, or greater than the value provided. Both the operator and value can be exposed to the user. Contextual filters lack this function, and must be equal to the value provided. Is there a specific reason that this was left out? I have edited the core StringArgument to give it the same operators as the StringFilter. Is there a reason (security, feature overlap) that I shouldn't submit this as a feature addition?

  • I have edited the core StringArgument Yikes, you violated the cardinal rule of Drupal, never hack core. You could achieve the same result with hook_views_query_alter.
    – No Sssweat
    Dec 30 '17 at 12:06
  • If you want to add a feature patch, you have to edit the core files. Dec 30 '17 at 12:57
  • However, if I did try to do this with a module, how would I completely override the existing query() function instead of altering it with the hook? It might be worthwhile doing this do demonstrate what the new function would look like and get some interest and adoption to push a core patch through. Dec 30 '17 at 13:07
  • Where is the query() that you speak of located?
    – No Sssweat
    Dec 31 '17 at 3:23
  • It’s in the core src/views/argument/StringArgument.php file..I think that name is correct, not in front of my computer right now. Dec 31 '17 at 4:04

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.