Drupal - Changing url of exposed filter

A colleague of mine created a module called path data a while back. His intentition was to solve this very problem. Unfortunately it has turned out that it conflicts with regular path aliases, so it will work on a site like drupal.org that doesn't use aliases, but will break links on a path-alias using site.

Currently, it's my belief that the only generic way to solve this issue is either manipulating the URLs at the httpd layer, or using hook_url_inbound_alter and hook_url_outbound_alter. You can read a bit more about the mentioned hooks at this question.

However, if I were to give this another shoot myself, I would attempt a Views specific solution instead, as this problem is common enough that it could be justified to have a module for this.

In hook_views_pre_build, one could take data from a url like "members/valuea/valueb", push these values into $_GET['q'], let views build it's query seeing the get arguments "in the url", then possibly remove them again in hook_views_post_build.


There is a module, Query Parameters To URL, that I recently released that addresses the issue you are describing:

This module provides the ability to rewrite URL query parameters into Clean URL components on specified paths.

You can configure which paths should have their query arguments rewritten as clean URL components using a simple regular expression, or by implementing a module hook.

That way you can transform a Views exposed filter URL like

http://example-site.com/events?field_category_id[0]=100&field_category_id1=101&field_author_name[0]=John&field_author_surname[0]=Doe

into http://example-site.com/events/p/field_category_id/0__100--1__101/field_author_name/0__John/field_author_surname/0__Doe

Underneath it uses hook_url_inbound_alter, hook_url_outbound_alter, and hook_init with redirects where necessary.

Tags:

Views

7