hook_views_plugins
Describes plugins defined by the module.
This hook should be placed in MODULENAME.views.inc and it will be
auto-loaded. MODULENAME.views.inc must be in the directory specified by the
'path' key returned by MODULENAME_views_api(), or the same directory as the
.module file, if 'path' is unspecified. All plugin files need to be
referenced in MODULENAME.info with the files[] directive.
Return value
An array on the form $plugins['PLUGIN TYPE']['PLUGIN NAME']. The plugin
must be one of row, display, display_extender, style, argument default,
argument validator, access, query, cache, pager, exposed_form or
localization. The plugin name should be prefixed with your module name.
The value for each entry is an associateive array that may contain the
following entries:
- Used by all plugin types:
- title (required): The name of the plugin, as shown in Views. Wrap in
t().
- handler (required): The name of the file containing the class
describing the handler, which must also be the name of the handler's
class.
- path: Path to the handler. Only required if the handler is not placed
in the same folder as the .module file or in the subfolder 'views'.
- parent: The name of the plugin this plugin extends. Since Drupal 7 this
is no longer required, but may still be useful from a code readability
perspective.
- no ui: Set to TRUE to denote that the plugin doesn't appear to be
selectable in the ui, though on the api side they still exists.
- uses options: Set to TRUE to denote that the plugin has an additional
options form.
- help: A short help text, wrapped in t() used as description on the plugin settings form.
- help topic: The name of an entry by advanced help for the plugin.
- theme: The name of a theme suggestion to use for the display.
- js: An array with paths to js files that should be included for the
display. Note that the path should be relative Drupal root, not module
root.
- type: Each plugin can specify a type parameter to group certain
plugins together. For example all row plugins related to feeds are
grouped together, because a rss style plugin only accepts feed row
plugins.
- Used by display plugins:
- admin: The administrative name of the display, as displayed on the
Views overview and also used as default name for new displays. Wrap in
t().
- no remove: Set to TRUE to make the display non-removable. (Basically
only used for the master/default display.)
- use ajax: Set to TRUE to allow AJAX loads in the display. If it's
disabled there will be no ajax option in the ui.
- use pager: Set to TRUE to allow paging in the display.
- use more: Set to TRUE to allow the 'use more' setting in the display.
- accept attachments: Set to TRUE to allow attachment displays to be
attached to this display type.
- contextual links locations: An array with places where contextual links
should be added. Can for example be 'page' or 'block'. If you don't
specify it there will be contextual links around the rendered view. If
this is not set or regions have been specified, views will display an
option to 'hide contextual links'. Use an empty array if you do not want
this.
- uses hook menu: Set to TRUE to have the display included by
views_menu_alter(). views_menu_alter executes then execute_hook_menu
on the display object.
- uses hook block: Set to TRUE to have the display included by
views_block_info().
- theme: The name of a theme suggestion to use for the display.
- js: An array with paths to js files that should be included for the
display. Note that the path should be relative Drupal root, not module
root.
- Used by style plugins:
- uses row plugin: Set to TRUE to allow row plugins for this style.
- uses row class: Set to TRUE to allow the CSS class settings for rows.
- uses fields: Set to TRUE to have the style plugin accept field
handlers.
- uses grouping: Set to TRUE to allow the grouping settings for rows.
- even empty: May have the value 'even empty' to tell Views that the style
should be rendered even if there are no results.
- Used by row plugins:
- uses fields: Set to TRUE to have the row plugin accept field handlers.
Related topics
- Views hooks
- Hooks that can be implemented by other modules in order to implement the
Views API.
File
- contributions/views/views.api.php, line 597
- Describe hooks provided by the Views module.
Code
function hook_views_plugins() {
$plugins = array();
$plugins['argument validator'] = array(
'taxonomy_term' => array(
'title' => t('Taxonomy term'),
'handler' => 'views_plugin_argument_validate_taxonomy_term',
'path' => drupal_get_path('module', 'views') . '/modules/taxonomy',
),
);
return array(
'module' => 'views', 'argument validator' => array(
'taxonomy_term' => array(
'title' => t('Taxonomy term'),
'handler' => 'views_plugin_argument_validate_taxonomy_term',
'path' => drupal_get_path('module', 'views') . '/modules/taxonomy', ),
),
'argument default' => array(
'taxonomy_tid' => array(
'title' => t('Taxonomy term ID from URL'),
'handler' => 'views_plugin_argument_default_taxonomy_tid',
'path' => drupal_get_path('module', 'views') . '/modules/taxonomy',
'parent' => 'fixed',
),
),
);
}