The views modify query creates a views filter that lets you run PHP code to modify the query when it is build. In addition, it provides a Views field that lets you display any output generated by the code in the filter. This can be very useful when developing sites.
This is a module for advanced developers only ; only use it if you know what you are doing and understand the Views API.
Using this module can cause data loss. Only use it on development sites, and only if you know what you are doing
The code is run in the context of the 'query' call of a 'views_handler_filter' object ; so $this exists and represents the said object.
No support or examples will be given. If you do not know how the Views module works, you can try the following to get started :
- In your View, add a filter, select group 'Views' and choose 'Views Modify Query'
- In the Views Modify Query filter, enter 'var_dump($this->query);' and save it
- Add a field (your view must display fields), select group 'Views' and choose 'Views Modify Query'
- Set the output to 'Escaped, enclosed with pre tags'. Save the field.
- Finally, click on 'preview' to view the result. Study the structrure of the query object. (Note that if your view didnt' return any rows, then you won't see any output)
- It would also be advisable to study the methods of the query object, which can be found on your site in modules/views/includes/query.inc
Once you've managed to write your own code to do what you like, I really advise you put it in your own module rather than use the Views Modify Query filter in a production site. You can use the Views Modify Query module as a squeleton, it's pretty simple.
Views 2.0 RC2
Unfortunately, the Views 2.0 RC2 release broke backward compatibility with Views modules. The latest version of Views Modify Query now works with RC2, and it is not compatible with Views prior to Views 2.0RC2.
Users who used VMQ with Views before RC2, will need to upgrade both ; and (sorry) will need to remove their old VMQ filters, and add new ones.
- Maintenance status: Unknown
- Development status: Unknown
- Module categories: Developer
- Downloads: 2,543
- Last modified: December 1, 2014