Not all Drupal developers know that the Views module provides a pretty wide API. In addition to a big hooks system, the functionality of views can be expanded with use of some additional plugins. There are 10 types of plugins to be applied to views. In the current article we will examine creation of a Display extender type plugin for the views, which facilitates adding your own settings to the display. Further on, these settings can be utilized in whatever place there's a need for the display to be called in.
So as to have the plugin realized we shall create a module, and announce hook_views_api() in it:
php /** * Implements hook_views_api(). */ function extender_example_views_api() { return array( 'api' => 3, ); }
Next, following the description in the documentation, we ought to call hook_views_plugins() in the extender_example.views.inc file:
php /** * Implements hook_views_plugins(). */ function extender_example_views_plugins() { $path = drupal_get_path('module', 'extender_example'); $plugins = array(); $plugins['display_extender']['extender_example'] = array( 'title' => t('Extender example textarea'), 'help' => t('Add textarea.'), 'path' => $path, 'handler' => 'extender_example_plugin_display_extender_code', ); return $plugins; }