As part of a port of a non-Drupal site to Drupal, I need to map a url query string to filters.

For example, if I have this query string and slect filter selected on Site A (Non-Drupal)

Site A

Value 1 | Value 1

Value 2 | Value 2

Value 3 | Value 3


Site B:

Value 1 |1

Value 2 |2

Value 3 |3


Site A cannot be edited. Is it possible to either edit the values in Site B to match that of site A (within views only, not actual field data) or map the query string, so that Views will see "www.sitea.com/?value=value%1" and display "www.sitea.com/?value=1"

I know I can change the Filter identifier (i.e. ?value) on the filter settings tab but how can I changed the values themselves?

In reality, they are far more complex than this so I'd like to avoid HTACESS.


You can use the hook_views_pre_view function in your custom module to change the query parameters using PHP, so a rough untested example of the code could look something like:

function MODULE_views_pre_view(&$view) {
  switch ($view->name) {
    case 'YOUR_VIEW_NAME': {
      // change your query strings to
      if ($_GET['value']) {
        $value = $_GET['value'];
        $new_value = substr($value, 0 , 6); // remove the 'value%' from Site A querystring
        $_GET['value'] = $new_value;

Use the module Views Contextual Filter Query It will fit your needs. enter image description here

  • this module queries to be used as contextual filters but how can it be used to map/rename query string values?
    – Sam
    Sep 23 '17 at 8:12

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.