0

Hi I would like to create a custom module where I can do extra checks on a view and if those checks are not pass deny access. I'm not sure what hook to implement to achieve this.

2
  • Do you menu or module? – acrosman Sep 6 '13 at 20:14
  • I'm sorry, custom module. – Brian Sep 6 '13 at 20:22
0

You need to implement two Views hooks: hook_views_api() and hook_views_plugins(). Have a look at views_views_plugins() in Views' /includes/plugins.inc file for an example implementation of the plugin hook; specifically, look at the plugins in the 'access' key.

Beyond that, look at the views_plugin_access* files in /plugins/ for examples of actual implementations.

4
  • I haven't done too much of this so please bear with me. So I create: – Brian Sep 6 '13 at 22:18
  • I haven't done too much of this so please bear with me. So I create the hook_views_api() which is essentially the version then I create MODULENAME.views.inc with the views_views_plugin() with the access section that has a handler to my custom plugin? I'm not really sure what to do with the handler? Just return t('Unrestricted'); if validation doesn't pass? – Brian Sep 6 '13 at 22:24
  • To be honest I can easily achieve what I want in the tpl file but I know this is not the drupal way and would like to do it correctly. – Brian Sep 6 '13 at 22:26
  • Never mind I was able to achieve what I wanted in template.php. Creating a module for this simple task seemed to create extra work that didn't need to be done. – Brian Sep 7 '13 at 13:32

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.