2

I have a complex View that needs to utilize multiple contextual filters. Currently to access the filters I need to separate the values with a "/". I'm attempting to code a solution that passes arguments to a View (via URL) and it would be ideal to have the query string look like this:

http://www.example.com/query?nid=1450&tid=543

vs (the current way)

http://www.example.com/query/1450/543

so that I can better parse this. How can I get a View to accept parameters like this?

2
  • Interesting, usually all requests of this sort are to do exactly the opposite (i.e. convert to clean URLs, not away from them). Not questioning your decisions, but is there a technical reason you'd want to do this? If the page is a Views page I wonder why you need to parse the parameters, when Views already does that for you
    – Clive
    Jun 19, 2013 at 13:48
  • In my case the parameters need to be shared with an external system. Would there be a better way for me to parse the parameters than parse_url?
    – Ken J
    Jun 19, 2013 at 16:17

2 Answers 2

3

What you're actually saying is that you don't want contextual filters, contextual means that you want an argument based on the context of the site which is usually separated out by the url.

The quickest way to do what you want is this.

  • move your contextual filters into the filters section of views, making sure that you expose them to visitors.
  • Under the more setting of each filter is where you set the filter identifier and change the advanced options to label the filter as you require such as "nid" then your url would be mywebsite.com/page?nid=xxx
  • Then under the exposed form settings, change the setting to "expose form as block" to yes to make the exposed filters disappear.
1
  • Sometimes the easiest solutions are the correct ones! Thanks!
    – Ken J
    Jun 19, 2013 at 19:52
0

You need the module Views Contextual Filter Query.

From the module page:

Allows url query values to be used as contextual filter arguments. This module is an answer to the many stackoverflow topics where the solution is to fetch query parameters by using the default PHP argument filter in Views (yucks!).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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