2

I want to modify query parameters used when accessing a Drupal page. I tried implementing hook_url_inbound_alter(), but it only allows to parse/modify the path, and it doesn't allow any interaction with the query string.

I see there is also drupal_get_query_parameters(), which allows to read the query parameters.

I could detect the presence of a query value in index.php and do a string replacement on the value if needed, but I don't want to pollute the front controller.

Do you have any better advice?

  • 1
    You would need to modify the global $_GET at some early stage, maybe hook_boot – Clive Feb 23 '18 at 13:42
0

1) you need to implement EventSubscriber, use KernelEvents::REQUEST in getSubscribedEvents() method

2) then you use \Drupal::request()->query->set('key', 'value');

  • Thanks for your answer but is this for Drupal 8? I am using 7. – ajmedway Mar 13 '18 at 10:04

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.