0

By default Views uses 'views_plugin_query_default' plugin. How can I alter something so that Views could use another class for building queries?

I found one good example how to write Views query plugins: building views query plugins

But this example is for custom tables. But I need to have my own query builder for ordinary node, terms and users tables.

1 Answer 1

0

Firstly you will need to have defined your query plugin to Views using hook_views_plugins():

function MYMODULE_views_plugins() {
  return array(
    'query' => array(
      'myplugin' => array(
        'title' => 'My custom plugin',
        'handler' => 'MyCustomQueryClass',
      ),
    ),
  );
}

Then, you should be able to override the query class used for any of the built-in tables using hook_views_data_alter() and setting the query class key in the table base property:

function MYMODULE_views_data_alter(&$data) {
    $data['node']['table']['base']['query class'] = 'myplugin';
}

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.