2009-05-17 11:16:51 +00:00
|
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @file
|
2012-10-14 00:26:52 +00:00
|
|
|
|
* Describes hooks and plugins provided by the Views module.
|
2009-05-17 11:16:51 +00:00
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
/**
|
2012-10-14 00:26:52 +00:00
|
|
|
|
* @defgroup views_plugins Views plugins
|
2009-05-17 11:16:51 +00:00
|
|
|
|
*
|
2012-10-14 00:26:52 +00:00
|
|
|
|
* Views plugins are objects that are used to build and render the view.
|
2012-10-10 15:52:33 +00:00
|
|
|
|
* Plugins are registered by extending one of the Views base plugin classes
|
|
|
|
|
* and defining settings in the plugin annotation.
|
2009-05-17 11:16:51 +00:00
|
|
|
|
*
|
2012-10-14 00:26:52 +00:00
|
|
|
|
* Views has the following types of plugins:
|
|
|
|
|
* - Access: Access plugins are responsible for controlling access to the
|
|
|
|
|
* view. Views includes plugins for checking user roles and individual
|
|
|
|
|
* permissions. Access plugins extend
|
2012-10-17 12:14:38 +00:00
|
|
|
|
* \Drupal\views\Plugin\views\access\AccessPluginBase.
|
2012-10-14 00:26:52 +00:00
|
|
|
|
* - Argument default: Argument default plugins allow pluggable ways of
|
|
|
|
|
* providing default values for contextual filters. This is useful for
|
|
|
|
|
* blocks and other display types lacking a natural argument input.
|
|
|
|
|
* Examples are plugins to extract node and user IDs from the URL. Argument
|
|
|
|
|
* default plugins extend
|
2012-10-17 12:14:38 +00:00
|
|
|
|
* \Drupal\views\Plugin\views\argument_default\ArgumentDefaultPluginBase.
|
2012-10-14 00:26:52 +00:00
|
|
|
|
* - Argument validator: Validator plugins can ensure arguments are valid,
|
|
|
|
|
* and even do transformations on the arguments. They can also provide
|
|
|
|
|
* replacement patterns for the view title. For example, the 'content'
|
|
|
|
|
* validator verifies verifies that the argument value corresponds to a
|
|
|
|
|
* node, loads that node and provides the node title as a replacement
|
|
|
|
|
* pattern. Argument validator plugins extend
|
2012-10-17 12:14:38 +00:00
|
|
|
|
* \Drupal\views\Plugin\views\argument_validator\ArgumentValidatorPluginBase.
|
2012-10-14 00:26:52 +00:00
|
|
|
|
* - Cache: Cache plugins control the storage and loading of caches.
|
|
|
|
|
* Currently they can do both result and render caching. It might also be
|
|
|
|
|
* possible to cache the generated query. Cache plugins extend
|
2012-10-17 12:14:38 +00:00
|
|
|
|
* \Drupal\views\Plugin\views\cache\CachePluginBase.
|
2012-10-14 00:26:52 +00:00
|
|
|
|
* - Display: Display plugins are responsible for controlling where a View is
|
|
|
|
|
* rendered; that is, how it is exposed to other parts of Drupal. 'Page'
|
|
|
|
|
* and 'block' are the most commonly used display plugins. Each View also
|
|
|
|
|
* has a 'master' (or 'default') display that includes information shared
|
|
|
|
|
* between all its displays. (See
|
2012-10-17 12:14:38 +00:00
|
|
|
|
* \Drupal\views\Plugin\views\display\DefaultDisplay.) Display plugins extend
|
|
|
|
|
* \Drupal\views\Plugin\views\display\DisplayPluginBase.
|
2012-10-14 00:26:52 +00:00
|
|
|
|
* - Display extender: Display extender plugins allow additional options or
|
|
|
|
|
* configurations to added to views across all display types. For example,
|
|
|
|
|
* if you wanted to allow site users to add certain metadata to the rendered
|
|
|
|
|
* output of every view display regardless of display type, you could provide
|
|
|
|
|
* this option as a display extender. Display extender plugins extend
|
2012-10-17 12:14:38 +00:00
|
|
|
|
* \Drupal\views\Plugin\views\display_extender\DisplayExtenderPluginBase.
|
2012-10-14 00:26:52 +00:00
|
|
|
|
* - Exposed form: Exposed form plugins are responsible for building,
|
|
|
|
|
* rendering, and controlling exposed forms. Exposed form plugins extend
|
2012-10-17 12:14:38 +00:00
|
|
|
|
* \Drupal\views\Plugin\views\display\DisplayPluginBase.
|
2012-10-14 00:26:52 +00:00
|
|
|
|
* - Handlers: Handler plugins help build the view query object that the query
|
|
|
|
|
* plugin then executes to retrieve the data from the storage backend (see
|
|
|
|
|
* below). There are several types of handlers:
|
2012-10-17 12:14:38 +00:00
|
|
|
|
* - Area handlers: Extend \Drupal\views\Plugin\views\area\AreaHandlerBase
|
2012-10-14 00:26:52 +00:00
|
|
|
|
* - Argument handlers: Extend
|
2012-10-17 12:14:38 +00:00
|
|
|
|
* \Drupal\views\Plugin\views\argument\ArgumentHandlerBase
|
|
|
|
|
* - Field handlers: Extend \Drupal\views\Plugin\views\field\FieldHandlerBase
|
2012-10-14 00:26:52 +00:00
|
|
|
|
* - Filter handlers: Extend
|
2012-10-17 12:14:38 +00:00
|
|
|
|
* \Drupal\views\Plugin\views\filter\FilterHandlerBase
|
2012-10-14 00:26:52 +00:00
|
|
|
|
* - Relationship handlers:
|
2012-10-17 12:14:38 +00:00
|
|
|
|
* Extend \Drupal\views\Plugin\views\relationship\RelationshipHandlerBase
|
|
|
|
|
* - Sort handlers: Extend \Drupal\views\Plugin\views\sort:SortHandlerBase
|
2012-10-14 00:26:52 +00:00
|
|
|
|
* - Pager: Pager plugins take care of everything regarding pagers, including
|
|
|
|
|
* getting setting the total number of items to render the pager and
|
|
|
|
|
* setting the global pager arrays. Pager plugins extend
|
2012-10-17 12:14:38 +00:00
|
|
|
|
* \Drupal\views\Plugin\views\pager\PagerPluginBase.
|
2012-10-14 00:26:52 +00:00
|
|
|
|
* - Query: Query plugins generate and execute a built query object against a
|
|
|
|
|
* particular storage backend, converting the Views query object into an
|
|
|
|
|
* actual query. The only default implementation is SQL. (Note that most
|
|
|
|
|
* handler plugins currently rely on the SQL query plugin.) Query plugins
|
2012-10-17 12:14:38 +00:00
|
|
|
|
* extend \Drupal\views\Plugin\views\query\QueryPluginBase.
|
2012-10-14 00:26:52 +00:00
|
|
|
|
* - Row style: Row styles handle rendering each individual record from the
|
|
|
|
|
* main view table. The two default implementations render the entire entity
|
|
|
|
|
* (nodes only), or selected fields. Row style plugins extend
|
2012-10-17 12:14:38 +00:00
|
|
|
|
* \Drupal\views\Plugin\views\row\RowPluginBase).
|
2012-10-14 00:26:52 +00:00
|
|
|
|
* - Style: Style plugins control how a view is displayed. For the most part
|
|
|
|
|
* they are object wrappers around theme templates. Examples of styles
|
|
|
|
|
* include HTML lists, tables, etc. Style plugins extend
|
2012-10-17 12:14:38 +00:00
|
|
|
|
* \Drupal\views\Plugin\views\style\StylePluginBase.
|
2012-10-14 00:26:52 +00:00
|
|
|
|
*
|
|
|
|
|
* @todo Add an explanation for each type of handler.
|
2012-10-10 15:52:33 +00:00
|
|
|
|
* @todo Document how to use annotations and what goes in them.
|
|
|
|
|
* @todo Add @ingroup to all the base plugins for this group.
|
|
|
|
|
* @todo Add a separate @ingroup for all plugins?
|
|
|
|
|
* @todo Document specific options on the appropriate plugin base classes.
|
|
|
|
|
* @todo Add examples.
|
2009-05-17 11:16:51 +00:00
|
|
|
|
*
|
2012-10-17 12:14:38 +00:00
|
|
|
|
* @see \Drupal\views\Plugin\views\PluginBase
|
|
|
|
|
* @see \Drupal\views\Plugin\views\HandlerBase
|
2009-05-17 11:16:51 +00:00
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @defgroup views_hooks Views hooks
|
|
|
|
|
* @{
|
2012-10-10 17:27:49 +00:00
|
|
|
|
* Hooks that allow other modules to implement the Views API.
|
2009-05-17 11:16:51 +00:00
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
/**
|
2012-10-20 15:36:59 +00:00
|
|
|
|
* Describe data tables (or the equivalent) to Views.
|
2012-07-27 12:43:10 +00:00
|
|
|
|
*
|
2012-10-21 11:01:01 +00:00
|
|
|
|
* The data described with this hook is fetched and retrieved by
|
2013-03-13 21:29:08 +00:00
|
|
|
|
* \Drupal\views\Views::viewsData()->get().
|
2012-10-21 11:01:01 +00:00
|
|
|
|
*
|
2012-10-20 15:36:59 +00:00
|
|
|
|
* @return array
|
2009-05-17 11:16:51 +00:00
|
|
|
|
* An associative array describing the data structure. Primary key is the
|
2012-07-27 12:43:10 +00:00
|
|
|
|
* name used internally by Views for the table(s) – usually the actual table
|
2009-05-17 11:16:51 +00:00
|
|
|
|
* name. The values for the key entries are described in detail below.
|
|
|
|
|
*/
|
|
|
|
|
function hook_views_data() {
|
|
|
|
|
// This example describes how to write hook_views_data() for the following
|
|
|
|
|
// table:
|
|
|
|
|
//
|
|
|
|
|
// CREATE TABLE example_table (
|
|
|
|
|
// nid INT(11) NOT NULL COMMENT 'Primary key; refers to {node}.nid.',
|
|
|
|
|
// plain_text_field VARCHAR(32) COMMENT 'Just a plain text field.',
|
|
|
|
|
// numeric_field INT(11) COMMENT 'Just a numeric field.',
|
|
|
|
|
// boolean_field INT(1) COMMENT 'Just an on/off field.',
|
|
|
|
|
// timestamp_field INT(8) COMMENT 'Just a timestamp field.',
|
|
|
|
|
// PRIMARY KEY(nid)
|
|
|
|
|
// );
|
|
|
|
|
|
|
|
|
|
// First, the entry $data['example_table']['table'] describes properties of
|
2012-07-27 12:43:10 +00:00
|
|
|
|
// the actual table – not its content.
|
2009-05-17 11:16:51 +00:00
|
|
|
|
|
|
|
|
|
// The 'group' index will be used as a prefix in the UI for any of this
|
|
|
|
|
// table's fields, sort criteria, etc. so it's easy to tell where they came
|
|
|
|
|
// from.
|
|
|
|
|
$data['example_table']['table']['group'] = t('Example table');
|
|
|
|
|
|
|
|
|
|
// Define this as a base table – a table that can be described in itself by
|
|
|
|
|
// views (and not just being brought in as a relationship). In reality this
|
|
|
|
|
// is not very useful for this table, as it isn't really a distinct object of
|
|
|
|
|
// its own, but it makes a good example.
|
|
|
|
|
$data['example_table']['table']['base'] = array(
|
|
|
|
|
'field' => 'nid', // This is the identifier field for the view.
|
|
|
|
|
'title' => t('Example table'),
|
|
|
|
|
'help' => t('Example table contains example content and can be related to nodes.'),
|
|
|
|
|
'weight' => -10,
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
// This table references the {node} table. The declaration below creates an
|
|
|
|
|
// 'implicit' relationship to the node table, so that when 'node' is the base
|
|
|
|
|
// table, the fields are automatically available.
|
|
|
|
|
$data['example_table']['table']['join'] = array(
|
|
|
|
|
// Index this array by the table name to which this table refers.
|
|
|
|
|
// 'left_field' is the primary key in the referenced table.
|
|
|
|
|
// 'field' is the foreign key in this table.
|
|
|
|
|
'node' => array(
|
|
|
|
|
'left_field' => 'nid',
|
|
|
|
|
'field' => 'nid',
|
|
|
|
|
),
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
// Next, describe each of the individual fields in this table to Views. This
|
|
|
|
|
// is done by describing $data['example_table']['FIELD_NAME']. This part of
|
|
|
|
|
// the array may then have further entries:
|
|
|
|
|
// - title: The label for the table field, as presented in Views.
|
|
|
|
|
// - help: The description text for the table field.
|
2012-07-27 12:43:10 +00:00
|
|
|
|
// - relationship: A description of any relationship handler for the table
|
|
|
|
|
// field.
|
2009-05-17 11:16:51 +00:00
|
|
|
|
// - field: A description of any field handler for the table field.
|
|
|
|
|
// - sort: A description of any sort handler for the table field.
|
|
|
|
|
// - filter: A description of any filter handler for the table field.
|
|
|
|
|
// - argument: A description of any argument handler for the table field.
|
|
|
|
|
// - area: A description of any handler for adding content to header,
|
|
|
|
|
// footer or as no result behaviour.
|
|
|
|
|
//
|
|
|
|
|
// The handler descriptions are described with examples below.
|
|
|
|
|
|
|
|
|
|
// Node ID table field.
|
|
|
|
|
$data['example_table']['nid'] = array(
|
|
|
|
|
'title' => t('Example content'),
|
|
|
|
|
'help' => t('Some example content that references a node.'),
|
2012-07-27 12:43:10 +00:00
|
|
|
|
// Define a relationship to the {node} table, so example_table views can
|
|
|
|
|
// add a relationship to nodes. If you want to define a relationship the
|
|
|
|
|
// other direction, use hook_views_data_alter(), or use the 'implicit' join
|
|
|
|
|
// method described above.
|
2009-05-17 11:16:51 +00:00
|
|
|
|
'relationship' => array(
|
2012-07-28 15:24:36 +00:00
|
|
|
|
'base' => 'node', // The name of the table to join with
|
|
|
|
|
'field' => 'nid', // The name of the field to join with
|
2012-08-11 11:46:07 +00:00
|
|
|
|
'id' => 'standard',
|
2012-07-28 15:24:36 +00:00
|
|
|
|
'label' => t('Example node'),
|
2009-05-17 11:16:51 +00:00
|
|
|
|
),
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
// Example plain text field.
|
|
|
|
|
$data['example_table']['plain_text_field'] = array(
|
|
|
|
|
'title' => t('Plain text field'),
|
|
|
|
|
'help' => t('Just a plain text field.'),
|
|
|
|
|
'field' => array(
|
2012-08-11 11:46:07 +00:00
|
|
|
|
'id' => 'standard',
|
2009-05-17 11:16:51 +00:00
|
|
|
|
),
|
|
|
|
|
'sort' => array(
|
2012-08-11 11:46:07 +00:00
|
|
|
|
'id' => 'standard',
|
2009-05-17 11:16:51 +00:00
|
|
|
|
),
|
|
|
|
|
'filter' => array(
|
2012-08-11 11:46:07 +00:00
|
|
|
|
'id' => 'string',
|
2009-05-17 11:16:51 +00:00
|
|
|
|
),
|
|
|
|
|
'argument' => array(
|
2012-08-11 11:46:07 +00:00
|
|
|
|
'id' => 'string',
|
2009-05-17 11:16:51 +00:00
|
|
|
|
),
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
// Example numeric text field.
|
|
|
|
|
$data['example_table']['numeric_field'] = array(
|
|
|
|
|
'title' => t('Numeric field'),
|
|
|
|
|
'help' => t('Just a numeric field.'),
|
|
|
|
|
'field' => array(
|
2012-08-11 11:46:07 +00:00
|
|
|
|
'id' => 'numeric',
|
2009-05-17 11:16:51 +00:00
|
|
|
|
),
|
|
|
|
|
'filter' => array(
|
2012-08-11 11:46:07 +00:00
|
|
|
|
'id' => 'numeric',
|
2009-05-17 11:16:51 +00:00
|
|
|
|
),
|
|
|
|
|
'sort' => array(
|
2012-08-11 11:46:07 +00:00
|
|
|
|
'id' => 'standard',
|
2009-05-17 11:16:51 +00:00
|
|
|
|
),
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
// Example boolean field.
|
|
|
|
|
$data['example_table']['boolean_field'] = array(
|
|
|
|
|
'title' => t('Boolean field'),
|
|
|
|
|
'help' => t('Just an on/off field.'),
|
|
|
|
|
'field' => array(
|
2012-08-11 11:46:07 +00:00
|
|
|
|
'id' => 'boolean',
|
2009-05-17 11:16:51 +00:00
|
|
|
|
),
|
|
|
|
|
'filter' => array(
|
2012-08-11 11:46:07 +00:00
|
|
|
|
'id' => 'boolean',
|
2009-05-17 11:16:51 +00:00
|
|
|
|
// Note that you can override the field-wide label:
|
|
|
|
|
'label' => t('Published'),
|
|
|
|
|
// This setting is used by the boolean filter handler, as possible option.
|
|
|
|
|
'type' => 'yes-no',
|
|
|
|
|
// use boolean_field = 1 instead of boolean_field <> 0 in WHERE statment.
|
2012-08-12 00:10:20 +00:00
|
|
|
|
'use_equal' => TRUE,
|
2009-05-17 11:16:51 +00:00
|
|
|
|
),
|
|
|
|
|
'sort' => array(
|
2012-08-11 11:46:07 +00:00
|
|
|
|
'id' => 'standard',
|
2009-05-17 11:16:51 +00:00
|
|
|
|
),
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
// Example timestamp field.
|
|
|
|
|
$data['example_table']['timestamp_field'] = array(
|
|
|
|
|
'title' => t('Timestamp field'),
|
|
|
|
|
'help' => t('Just a timestamp field.'),
|
|
|
|
|
'field' => array(
|
2012-08-11 11:46:07 +00:00
|
|
|
|
'id' => 'date',
|
2009-05-17 11:16:51 +00:00
|
|
|
|
),
|
|
|
|
|
'sort' => array(
|
2012-08-11 11:46:07 +00:00
|
|
|
|
'id' => 'date',
|
2009-05-17 11:16:51 +00:00
|
|
|
|
),
|
|
|
|
|
'filter' => array(
|
2012-08-11 11:46:07 +00:00
|
|
|
|
'id' => 'date',
|
2009-05-17 11:16:51 +00:00
|
|
|
|
),
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
return $data;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
2012-10-20 15:36:59 +00:00
|
|
|
|
* Alter the table structure defined by hook_views_data().
|
2009-05-17 11:16:51 +00:00
|
|
|
|
*
|
2012-10-20 15:36:59 +00:00
|
|
|
|
* @param array $data
|
2012-07-27 12:43:10 +00:00
|
|
|
|
* An array of all Views data, passed by reference. See hook_views_data() for
|
|
|
|
|
* structure.
|
2009-05-17 11:16:51 +00:00
|
|
|
|
*
|
|
|
|
|
* @see hook_views_data()
|
|
|
|
|
*/
|
2012-10-20 15:36:59 +00:00
|
|
|
|
function hook_views_data_alter(array &$data) {
|
2012-07-27 12:43:10 +00:00
|
|
|
|
// This example alters the title of the node:nid field in the Views UI.
|
2009-05-17 11:16:51 +00:00
|
|
|
|
$data['node']['nid']['title'] = t('Node-Nid');
|
|
|
|
|
|
2012-07-27 12:43:10 +00:00
|
|
|
|
// This example adds an example field to the users table.
|
2009-05-17 11:16:51 +00:00
|
|
|
|
$data['users']['example_field'] = array(
|
|
|
|
|
'title' => t('Example field'),
|
|
|
|
|
'help' => t('Some example content that references a user'),
|
|
|
|
|
'handler' => 'hook_handlers_field_example_field',
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
// This example changes the handler of the node title field.
|
2012-07-27 12:43:10 +00:00
|
|
|
|
// In this handler you could do stuff, like preview of the node when clicking
|
2009-05-17 11:16:51 +00:00
|
|
|
|
// the node title.
|
|
|
|
|
$data['node']['title']['handler'] = 'modulename_handlers_field_node_title';
|
|
|
|
|
|
2012-07-27 12:43:10 +00:00
|
|
|
|
// This example adds a relationship to table {foo}, so that 'foo' views can
|
|
|
|
|
// add this table using a relationship. Because we don't want to write over
|
|
|
|
|
// the primary key field definition for the {foo}.fid field, we use a dummy
|
|
|
|
|
// field name as the key.
|
|
|
|
|
$data['foo']['dummy_name'] = array(
|
|
|
|
|
'title' => t('Example relationship'),
|
|
|
|
|
'help' => t('Example help'),
|
|
|
|
|
'relationship' => array(
|
|
|
|
|
'base' => 'example_table', // Table we're joining to.
|
|
|
|
|
'base field' => 'eid', // Field on the joined table.
|
|
|
|
|
'field' => 'fid', // Real field name on the 'foo' table.
|
2012-08-11 11:46:07 +00:00
|
|
|
|
'id' => 'standard',
|
2012-07-27 12:43:10 +00:00
|
|
|
|
'label' => t('Default label for relationship'),
|
|
|
|
|
'title' => t('Title seen when adding relationship'),
|
|
|
|
|
'help' => t('More information about relationship.'),
|
|
|
|
|
),
|
|
|
|
|
);
|
|
|
|
|
|
2009-05-17 11:16:51 +00:00
|
|
|
|
// Note that the $data array is not returned – it is modified by reference.
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
2012-10-10 21:54:32 +00:00
|
|
|
|
* Replace special strings in the query before it is executed.
|
2009-05-17 11:16:51 +00:00
|
|
|
|
*
|
2012-10-17 12:14:38 +00:00
|
|
|
|
* @param \Drupal\views\ViewExecutable $view
|
2009-05-17 11:16:51 +00:00
|
|
|
|
* The View being executed.
|
2012-10-10 21:54:32 +00:00
|
|
|
|
* @return array
|
|
|
|
|
* An associative array where each key is a string to be replaced, and the
|
|
|
|
|
* corresponding value is its replacement. The strings to replace are often
|
|
|
|
|
* surrounded with '***', as illustrated in the example implementation.
|
2009-05-17 11:16:51 +00:00
|
|
|
|
*/
|
2012-10-10 21:54:32 +00:00
|
|
|
|
function hook_views_query_substitutions(ViewExecutable $view) {
|
2009-05-17 11:16:51 +00:00
|
|
|
|
// Example from views_views_query_substitutions().
|
|
|
|
|
return array(
|
|
|
|
|
'***CURRENT_VERSION***' => VERSION,
|
|
|
|
|
'***CURRENT_TIME***' => REQUEST_TIME,
|
2013-05-25 20:12:45 +00:00
|
|
|
|
'***CURRENT_LANGUAGE***' => language(\Drupal\Core\Language\Language::TYPE_CONTENT)->langcode,
|
2012-05-15 16:46:04 +00:00
|
|
|
|
'***DEFAULT_LANGUAGE***' => language_default()->langcode,
|
2009-05-17 11:16:51 +00:00
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
2012-10-10 21:54:32 +00:00
|
|
|
|
* Replace special strings when processing a view with form elements.
|
2009-05-17 11:16:51 +00:00
|
|
|
|
*
|
2012-10-10 21:54:32 +00:00
|
|
|
|
* @return array
|
|
|
|
|
* An associative array where each key is a string to be replaced, and the
|
|
|
|
|
* corresponding value is its replacement.
|
2009-05-17 11:16:51 +00:00
|
|
|
|
*/
|
|
|
|
|
function hook_views_form_substitutions() {
|
|
|
|
|
return array(
|
|
|
|
|
'<!--views-form-example-substitutions-->' => 'Example Substitution',
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
2012-10-10 21:57:31 +00:00
|
|
|
|
* Alter a view at the very beginning of Views processing.
|
2009-05-17 11:16:51 +00:00
|
|
|
|
*
|
2012-10-10 21:57:31 +00:00
|
|
|
|
* Output can be added to the view by setting $view->attachment_before
|
|
|
|
|
* and $view->attachment_after.
|
|
|
|
|
*
|
2012-10-17 12:14:38 +00:00
|
|
|
|
* @param \Drupal\views\ViewExecutable $view
|
2009-05-17 11:16:51 +00:00
|
|
|
|
* The view object about to be processed.
|
2012-10-10 21:57:31 +00:00
|
|
|
|
* @param string $display_id
|
2009-05-17 11:16:51 +00:00
|
|
|
|
* The machine name of the active display.
|
2012-10-10 21:57:31 +00:00
|
|
|
|
* @param array $args
|
2009-05-17 11:16:51 +00:00
|
|
|
|
* An array of arguments passed into the view.
|
2012-10-15 01:42:28 +00:00
|
|
|
|
*
|
2012-10-17 12:14:38 +00:00
|
|
|
|
* @see \Drupal\views\ViewExecutable
|
2009-05-17 11:16:51 +00:00
|
|
|
|
*/
|
2012-10-10 21:57:31 +00:00
|
|
|
|
function hook_views_pre_view(ViewExecutable &$view, &$display_id, array &$args) {
|
2009-05-17 11:16:51 +00:00
|
|
|
|
// Change the display if the acting user has 'administer site configuration'
|
|
|
|
|
// permission, to display something radically different.
|
2012-10-10 21:57:31 +00:00
|
|
|
|
// @todo Note that this is not necessarily the best way to solve that task.
|
|
|
|
|
// Add a better example.
|
|
|
|
|
if ($view->name == 'my_special_view' && user_access('administer site configuration') && $display_id == 'public_display') {
|
2009-05-17 11:16:51 +00:00
|
|
|
|
$display_id = 'private_display';
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
2012-10-10 21:57:31 +00:00
|
|
|
|
* Act on the view before the query is built, but after displays are attached.
|
2009-05-17 11:16:51 +00:00
|
|
|
|
*
|
2012-10-10 21:57:31 +00:00
|
|
|
|
* Output can be added to the view by setting $view->attachment_before
|
|
|
|
|
* and $view->attachment_after.
|
|
|
|
|
*
|
2012-10-17 12:14:38 +00:00
|
|
|
|
* @param \Drupal\views\ViewExecutable $view
|
2009-05-17 11:16:51 +00:00
|
|
|
|
* The view object about to be processed.
|
2012-10-15 01:42:28 +00:00
|
|
|
|
*
|
2012-10-17 12:14:38 +00:00
|
|
|
|
* @see \Drupal\views\ViewExecutable
|
2009-05-17 11:16:51 +00:00
|
|
|
|
*/
|
2012-10-10 21:57:31 +00:00
|
|
|
|
function hook_views_pre_build(ViewExecutable &$view) {
|
2009-05-17 11:16:51 +00:00
|
|
|
|
// Because of some unexplicable business logic, we should remove all
|
|
|
|
|
// attachments from all views on Mondays.
|
|
|
|
|
// (This alter could be done later in the execution process as well.)
|
|
|
|
|
if (date('D') == 'Mon') {
|
|
|
|
|
unset($view->attachment_before);
|
|
|
|
|
unset($view->attachment_after);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
2012-10-10 21:57:31 +00:00
|
|
|
|
* Act on the view immediately after the query is built.
|
2009-05-17 11:16:51 +00:00
|
|
|
|
*
|
2012-10-10 21:57:31 +00:00
|
|
|
|
* Output can be added to the view by setting $view->attachment_before
|
|
|
|
|
* and $view->attachment_after.
|
|
|
|
|
*
|
2012-10-17 12:14:38 +00:00
|
|
|
|
* @param \Drupal\views\ViewExecutable $view
|
2009-05-17 11:16:51 +00:00
|
|
|
|
* The view object about to be processed.
|
2012-10-15 01:42:28 +00:00
|
|
|
|
*
|
2012-10-17 12:14:38 +00:00
|
|
|
|
* @see \Drupal\views\ViewExecutable
|
2009-05-17 11:16:51 +00:00
|
|
|
|
*/
|
2012-10-10 21:57:31 +00:00
|
|
|
|
function hook_views_post_build(ViewExecutable &$view) {
|
2009-05-17 11:16:51 +00:00
|
|
|
|
// If the exposed field 'type' is set, hide the column containing the content
|
|
|
|
|
// type. (Note that this is a solution for a particular view, and makes
|
|
|
|
|
// assumptions about both exposed filter settings and the fields in the view.
|
|
|
|
|
// Also note that this alter could be done at any point before the view being
|
|
|
|
|
// rendered.)
|
|
|
|
|
if ($view->name == 'my_view' && isset($view->exposed_raw_input['type']) && $view->exposed_raw_input['type'] != 'All') {
|
|
|
|
|
// 'Type' should be interpreted as content type.
|
|
|
|
|
if (isset($view->field['type'])) {
|
|
|
|
|
$view->field['type']->options['exclude'] = TRUE;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
2012-10-10 21:57:31 +00:00
|
|
|
|
* Act on the view after the query is built and just before it is executed.
|
2009-05-17 11:16:51 +00:00
|
|
|
|
*
|
2012-10-10 21:57:31 +00:00
|
|
|
|
* Output can be added to the view by setting $view->attachment_before
|
|
|
|
|
* and $view->attachment_after.
|
|
|
|
|
*
|
2012-10-17 12:14:38 +00:00
|
|
|
|
* @param \Drupal\views\ViewExecutable $view
|
2009-05-17 11:16:51 +00:00
|
|
|
|
* The view object about to be processed.
|
2012-10-15 01:42:28 +00:00
|
|
|
|
*
|
2012-10-17 12:14:38 +00:00
|
|
|
|
* @see \Drupal\views\ViewExecutable
|
2009-05-17 11:16:51 +00:00
|
|
|
|
*/
|
2012-10-10 21:57:31 +00:00
|
|
|
|
function hook_views_pre_execute(ViewExecutable &$view) {
|
2009-05-17 11:16:51 +00:00
|
|
|
|
// Whenever a view queries more than two tables, show a message that notifies
|
|
|
|
|
// view administrators that the query might be heavy.
|
|
|
|
|
// (This action could be performed later in the execution process, but not
|
|
|
|
|
// earlier.)
|
|
|
|
|
if (count($view->query->tables) > 2 && user_access('administer views')) {
|
|
|
|
|
drupal_set_message(t('The view %view may be heavy to execute.', array('%view' => $view->name)), 'warning');
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
2012-10-10 21:57:31 +00:00
|
|
|
|
* Act on the view immediately after the query has been executed.
|
2009-05-17 11:16:51 +00:00
|
|
|
|
*
|
2012-10-10 21:57:31 +00:00
|
|
|
|
* At this point the query has been executed, but the pre_render() phase has
|
|
|
|
|
* not yet happened for handlers.
|
|
|
|
|
*
|
|
|
|
|
* Output can be added to the view by setting $view->attachment_before
|
|
|
|
|
* and $view->attachment_after.
|
|
|
|
|
*
|
2012-10-17 12:14:38 +00:00
|
|
|
|
* @param \Drupal\views\ViewExecutable $view
|
2009-05-17 11:16:51 +00:00
|
|
|
|
* The view object about to be processed.
|
2012-10-15 01:42:28 +00:00
|
|
|
|
*
|
2012-10-17 12:14:38 +00:00
|
|
|
|
* @see \Drupal\views\ViewExecutable
|
2009-05-17 11:16:51 +00:00
|
|
|
|
*/
|
2012-10-10 21:57:31 +00:00
|
|
|
|
function hook_views_post_execute(ViewExecutable &$view) {
|
2009-05-17 11:16:51 +00:00
|
|
|
|
// If there are more than 100 results, show a message that encourages the user
|
|
|
|
|
// to change the filter settings.
|
|
|
|
|
// (This action could be performed later in the execution process, but not
|
|
|
|
|
// earlier.)
|
|
|
|
|
if ($view->total_rows > 100) {
|
|
|
|
|
drupal_set_message(t('You have more than 100 hits. Use the filter settings to narrow down your list.'));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
2012-10-10 21:57:31 +00:00
|
|
|
|
* Act on the view immediately before rendering it.
|
2009-05-17 11:16:51 +00:00
|
|
|
|
*
|
2012-10-10 21:57:31 +00:00
|
|
|
|
* At this point the query has been executed, and the pre_render() phase has
|
|
|
|
|
* already happened for handlers, so all data should be available. This hook
|
|
|
|
|
* can be utilized by themes.
|
2009-05-17 11:16:51 +00:00
|
|
|
|
*
|
2012-10-10 21:57:31 +00:00
|
|
|
|
* Output can be added to the view by setting $view->attachment_before
|
|
|
|
|
* and $view->attachment_after.
|
|
|
|
|
*
|
2012-10-17 12:14:38 +00:00
|
|
|
|
* @param \Drupal\views\ViewExecutable $view
|
2009-05-17 11:16:51 +00:00
|
|
|
|
* The view object about to be processed.
|
2012-10-15 01:42:28 +00:00
|
|
|
|
*
|
2012-10-17 12:14:38 +00:00
|
|
|
|
* @see \Drupal\views\ViewExecutable
|
2009-05-17 11:16:51 +00:00
|
|
|
|
*/
|
2012-10-10 21:57:31 +00:00
|
|
|
|
function hook_views_pre_render(ViewExecutable &$view) {
|
2009-05-17 11:16:51 +00:00
|
|
|
|
// Scramble the order of the rows shown on this result page.
|
|
|
|
|
// Note that this could be done earlier, but not later in the view execution
|
|
|
|
|
// process.
|
|
|
|
|
shuffle($view->result);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
2012-10-10 21:57:31 +00:00
|
|
|
|
* Post-process any rendered data.
|
2009-05-17 11:16:51 +00:00
|
|
|
|
*
|
|
|
|
|
* This can be valuable to be able to cache a view and still have some level of
|
|
|
|
|
* dynamic output. In an ideal world, the actual output will include HTML
|
2012-10-10 21:57:31 +00:00
|
|
|
|
* comment-based tokens, and then the post process can replace those tokens.
|
|
|
|
|
* This hook can be utilized by themes.
|
2009-05-17 11:16:51 +00:00
|
|
|
|
*
|
|
|
|
|
* Example usage. If it is known that the view is a node view and that the
|
|
|
|
|
* primary field will be a nid, you can do something like this:
|
2012-10-10 21:57:31 +00:00
|
|
|
|
* @code
|
|
|
|
|
* <!--post-FIELD-NID-->
|
|
|
|
|
* @encode
|
|
|
|
|
* And then in the post-render, create an array with the text that should
|
2009-05-17 11:16:51 +00:00
|
|
|
|
* go there:
|
2012-10-10 21:57:31 +00:00
|
|
|
|
* @code
|
|
|
|
|
* strtr($output, array('<!--post-FIELD-1-->' => 'output for FIELD of nid 1');
|
|
|
|
|
* @encode
|
2009-05-17 11:16:51 +00:00
|
|
|
|
* All of the cached result data will be available in $view->result, as well,
|
|
|
|
|
* so all ids used in the query should be discoverable.
|
|
|
|
|
*
|
2012-10-17 12:14:38 +00:00
|
|
|
|
* @param \Drupal\views\ViewExecutable $view
|
2009-05-17 11:16:51 +00:00
|
|
|
|
* The view object about to be processed.
|
2012-10-10 21:57:31 +00:00
|
|
|
|
* @param string $output
|
2009-05-17 11:16:51 +00:00
|
|
|
|
* A flat string with the rendered output of the view.
|
2012-10-10 21:57:31 +00:00
|
|
|
|
* @param CacheBackendInterface $cache
|
2009-05-17 11:16:51 +00:00
|
|
|
|
* The cache settings.
|
2012-10-15 01:42:28 +00:00
|
|
|
|
*
|
2012-10-17 12:14:38 +00:00
|
|
|
|
* @see \Drupal\views\ViewExecutable
|
2009-05-17 11:16:51 +00:00
|
|
|
|
*/
|
2012-10-10 21:57:31 +00:00
|
|
|
|
function hook_views_post_render(ViewExecutable &$view, &$output, CacheBackendInterface &$cache) {
|
|
|
|
|
// When using full pager, disable any time-based caching if there are fewer
|
|
|
|
|
// than 10 results.
|
|
|
|
|
if ($view->pager instanceof Drupal\views\Plugin\views\pager\Full && $cache instanceof Drupal\views\Plugin\views\cache\Time && count($view->result) < 10) {
|
|
|
|
|
$cache->options['results_lifespan'] = 0;
|
|
|
|
|
$cache->options['output_lifespan'] = 0;
|
2009-05-17 11:16:51 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
2012-10-15 01:43:11 +00:00
|
|
|
|
* Alter the query before it is executed.
|
2009-05-17 11:16:51 +00:00
|
|
|
|
*
|
2012-10-17 12:14:38 +00:00
|
|
|
|
* @param \Drupal\views\ViewExecutable $view
|
2009-05-17 11:16:51 +00:00
|
|
|
|
* The view object about to be processed.
|
2012-10-15 01:43:11 +00:00
|
|
|
|
* @param QueryPluginBase $query
|
|
|
|
|
* The query plugin object for the query.
|
|
|
|
|
*
|
2009-05-17 11:16:51 +00:00
|
|
|
|
* @see hook_views_query_substitutions()
|
2012-10-17 12:14:38 +00:00
|
|
|
|
* @see \Drupal\views\Plugin\views\query\Sql
|
2009-05-17 11:16:51 +00:00
|
|
|
|
*/
|
2012-10-15 01:43:11 +00:00
|
|
|
|
function hook_views_query_alter(ViewExecutable &$view, QueryPluginBase &$query) {
|
2009-05-17 11:16:51 +00:00
|
|
|
|
// (Example assuming a view with an exposed filter on node title.)
|
|
|
|
|
// If the input for the title filter is a positive integer, filter against
|
|
|
|
|
// node ID instead of node title.
|
|
|
|
|
if ($view->name == 'my_view' && is_numeric($view->exposed_raw_input['title']) && $view->exposed_raw_input['title'] > 0) {
|
|
|
|
|
// Traverse through the 'where' part of the query.
|
|
|
|
|
foreach ($query->where as &$condition_group) {
|
|
|
|
|
foreach ($condition_group['conditions'] as &$condition) {
|
|
|
|
|
// If this is the part of the query filtering on title, chang the
|
|
|
|
|
// condition to filter on node ID.
|
|
|
|
|
if ($condition['field'] == 'node.title') {
|
|
|
|
|
$condition = array(
|
|
|
|
|
'field' => 'node.nid',
|
|
|
|
|
'value' => $view->exposed_raw_input['title'],
|
|
|
|
|
'operator' => '=',
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
2012-10-21 21:31:57 +00:00
|
|
|
|
* Alter the view preview information.
|
|
|
|
|
*
|
|
|
|
|
* The view preview information is optionally displayed when a view is
|
|
|
|
|
* previewed in the administrative UI. It includes query and performance
|
|
|
|
|
* statistics.
|
2009-05-17 11:16:51 +00:00
|
|
|
|
*
|
2012-10-15 01:43:11 +00:00
|
|
|
|
* @param array $rows
|
2009-05-17 11:16:51 +00:00
|
|
|
|
* An associative array with two keys:
|
|
|
|
|
* - query: An array of rows suitable for theme('table'), containing
|
|
|
|
|
* information about the query and the display title and path.
|
|
|
|
|
* - statistics: An array of rows suitable for theme('table'), containing
|
|
|
|
|
* performance statistics.
|
2012-10-17 12:14:38 +00:00
|
|
|
|
* @param \Drupal\views\ViewExecutable $view
|
2009-05-17 11:16:51 +00:00
|
|
|
|
* The view object.
|
2012-10-15 01:43:11 +00:00
|
|
|
|
*
|
2012-10-17 12:14:38 +00:00
|
|
|
|
* @see \Drupal\views_ui\ViewUI
|
2009-05-17 11:16:51 +00:00
|
|
|
|
* @see theme_table()
|
|
|
|
|
*/
|
2012-10-15 01:43:11 +00:00
|
|
|
|
function hook_views_preview_info_alter(array &$rows, ViewExecutable $view) {
|
2009-05-17 11:16:51 +00:00
|
|
|
|
// Adds information about the tables being queried by the view to the query
|
|
|
|
|
// part of the info box.
|
|
|
|
|
$rows['query'][] = array(
|
|
|
|
|
t('<strong>Table queue</strong>'),
|
|
|
|
|
count($view->query->table_queue) . ': (' . implode(', ', array_keys($view->query->table_queue)) . ')',
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
2012-10-21 21:31:57 +00:00
|
|
|
|
* Alter the links displayed at the top of the view edit form.
|
|
|
|
|
*
|
|
|
|
|
* @param array $links
|
|
|
|
|
* A renderable array of links which will be displayed at the top of the
|
|
|
|
|
* view edit form. Each entry will be in a form suitable for theme('link').
|
|
|
|
|
* @param \Drupal\views\ViewExecutable $view
|
|
|
|
|
* The view object being edited.
|
|
|
|
|
* @param string $display_id
|
|
|
|
|
* The ID of the display being edited, e.g. 'default' or 'page_1'.
|
|
|
|
|
*
|
|
|
|
|
* @see \Drupal\views_ui\ViewUI::renderDisplayTop()
|
2009-05-17 11:16:51 +00:00
|
|
|
|
*/
|
2012-10-21 21:31:57 +00:00
|
|
|
|
function hook_views_ui_display_top_links_alter(array &$links, ViewExecutable $view, $display_id) {
|
2009-05-17 11:16:51 +00:00
|
|
|
|
// Put the export link first in the list.
|
|
|
|
|
if (isset($links['export'])) {
|
|
|
|
|
$links = array('export' => $links['export']) + $links;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2013-02-07 14:11:14 +00:00
|
|
|
|
// @todo Describe how to alter a view ajax response with event listeners.
|
2009-05-17 11:16:51 +00:00
|
|
|
|
|
2012-08-12 15:52:02 +00:00
|
|
|
|
/**
|
2012-10-21 21:31:57 +00:00
|
|
|
|
* Allow modules to respond to the invalidation of the Views cache.
|
2012-08-12 15:52:02 +00:00
|
|
|
|
*
|
2012-10-21 21:31:57 +00:00
|
|
|
|
* This hook will fire whenever a view is enabled, disabled, created,
|
2012-08-12 15:52:02 +00:00
|
|
|
|
* updated, or deleted.
|
|
|
|
|
*
|
|
|
|
|
* @see views_invalidate_cache()
|
|
|
|
|
*/
|
|
|
|
|
function hook_views_invalidate_cache() {
|
2012-10-03 21:22:33 +00:00
|
|
|
|
cache('mymodule')->invalidateTags(array('views' => TRUE));
|
2012-08-12 15:52:02 +00:00
|
|
|
|
}
|
|
|
|
|
|
2013-06-09 12:35:39 +00:00
|
|
|
|
/**
|
|
|
|
|
* Modify the list of available views access plugins.
|
|
|
|
|
*
|
|
|
|
|
* This hook may be used to modify plugin properties after they have been
|
|
|
|
|
* specified by other modules.
|
|
|
|
|
*
|
|
|
|
|
* @param array $plugins
|
|
|
|
|
* An array of all the existing plugin definitions, passed by reference.
|
|
|
|
|
*
|
|
|
|
|
* @see \Drupal\views\Plugin\ViewsPluginManager
|
|
|
|
|
*/
|
|
|
|
|
function hook_views_plugins_access_alter(array &$plugins) {
|
|
|
|
|
// Remove the available plugin because the users should not have access to it.
|
|
|
|
|
unset($plugins['role']);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Modify the list of available views default argument plugins.
|
|
|
|
|
*
|
|
|
|
|
* This hook may be used to modify plugin properties after they have been
|
|
|
|
|
* specified by other modules.
|
|
|
|
|
*
|
|
|
|
|
* @param array $plugins
|
|
|
|
|
* An array of all the existing plugin definitions, passed by reference.
|
|
|
|
|
*
|
|
|
|
|
* @see \Drupal\views\Plugin\ViewsPluginManager
|
|
|
|
|
*/
|
|
|
|
|
function hook_views_plugins_argument_default_alter(array &$plugins) {
|
|
|
|
|
// Remove the available plugin because the users should not have access to it.
|
|
|
|
|
unset($plugins['php']);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Modify the list of available views argument validation plugins.
|
|
|
|
|
*
|
|
|
|
|
* This hook may be used to modify plugin properties after they have been
|
|
|
|
|
* specified by other modules.
|
|
|
|
|
*
|
|
|
|
|
* @param array $plugins
|
|
|
|
|
* An array of all the existing plugin definitions, passed by reference.
|
|
|
|
|
*
|
|
|
|
|
* @see \Drupal\views\Plugin\ViewsPluginManager
|
|
|
|
|
*/
|
|
|
|
|
function hook_views_plugins_argument_validator_alter(array &$plugins) {
|
|
|
|
|
// Remove the available plugin because the users should not have access to it.
|
|
|
|
|
unset($plugins['php']);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Modify the list of available views cache plugins.
|
|
|
|
|
*
|
|
|
|
|
* This hook may be used to modify plugin properties after they have been
|
|
|
|
|
* specified by other modules.
|
|
|
|
|
*
|
|
|
|
|
* @param array $plugins
|
|
|
|
|
* An array of all the existing plugin definitions, passed by reference.
|
|
|
|
|
*
|
|
|
|
|
* @see \Drupal\views\Plugin\ViewsPluginManager
|
|
|
|
|
*/
|
|
|
|
|
function hook_views_plugins_cache_alter(array &$plugins) {
|
|
|
|
|
// Change the title.
|
|
|
|
|
$plugins['time']['title'] = t('Custom title');
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Modify the list of available views display extender plugins.
|
|
|
|
|
*
|
|
|
|
|
* This hook may be used to modify plugin properties after they have been
|
|
|
|
|
* specified by other modules.
|
|
|
|
|
*
|
|
|
|
|
* @param array $plugins
|
|
|
|
|
* An array of all the existing plugin definitions, passed by reference.
|
|
|
|
|
*
|
|
|
|
|
* @see \Drupal\views\Plugin\ViewsPluginManager
|
|
|
|
|
*/
|
|
|
|
|
function hook_views_plugins_display_extenders_alter(array &$plugins) {
|
|
|
|
|
// Alter the title of an existing plugin.
|
|
|
|
|
$plugins['time']['title'] = t('Custom title');
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Modify the list of available views display plugins.
|
|
|
|
|
*
|
|
|
|
|
* This hook may be used to modify plugin properties after they have been
|
|
|
|
|
* specified by other modules.
|
|
|
|
|
*
|
|
|
|
|
* @param array $plugins
|
|
|
|
|
* An array of all the existing plugin definitions, passed by reference.
|
|
|
|
|
*
|
|
|
|
|
* @see \Drupal\views\Plugin\ViewsPluginManager
|
|
|
|
|
*/
|
|
|
|
|
function hook_views_plugins_display_alter(array &$plugins) {
|
|
|
|
|
// Alter the title of an existing plugin.
|
|
|
|
|
$plugins['rest_export']['title'] = t('Export');
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Modify the list of available views exposed form plugins.
|
|
|
|
|
*
|
|
|
|
|
* This hook may be used to modify plugin properties after they have been
|
|
|
|
|
* specified by other modules.
|
|
|
|
|
*
|
|
|
|
|
* @param array $plugins
|
|
|
|
|
* An array of all the existing plugin definitions, passed by reference.
|
|
|
|
|
*
|
|
|
|
|
* @see \Drupal\views\Plugin\ViewsPluginManager
|
|
|
|
|
*/
|
|
|
|
|
function hook_views_plugins_exposed_form_alter(array &$plugins) {
|
|
|
|
|
// Remove the available plugin because the users should not have access to it.
|
|
|
|
|
unset($plugins['input_required']);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Modify the list of available views join plugins.
|
|
|
|
|
*
|
|
|
|
|
* This hook may be used to modify plugin properties after they have been
|
|
|
|
|
* specified by other modules.
|
|
|
|
|
*
|
|
|
|
|
* @param array $plugins
|
|
|
|
|
* An array of all the existing plugin definitions, passed by reference.
|
|
|
|
|
*
|
|
|
|
|
* @see \Drupal\views\Plugin\ViewsPluginManager
|
|
|
|
|
*/
|
|
|
|
|
function hook_views_plugins_join_alter(array &$plugins) {
|
|
|
|
|
// Print out all join plugin names for debugging purposes.
|
|
|
|
|
debug($plugins);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Modify the list of available views join plugins.
|
|
|
|
|
*
|
|
|
|
|
* This hook may be used to modify plugin properties after they have been
|
|
|
|
|
* specified by other modules.
|
|
|
|
|
*
|
|
|
|
|
* @param array $plugins
|
|
|
|
|
* An array of all the existing plugin definitions, passed by reference.
|
|
|
|
|
*
|
|
|
|
|
* @see \Drupal\views\Plugin\ViewsPluginManager
|
|
|
|
|
*/
|
|
|
|
|
function hook_views_plugins_pager_alter(array &$plugins) {
|
|
|
|
|
// Remove the sql based plugin to force good performance.
|
|
|
|
|
unset($plugins['full']);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Modify the list of available views query plugins.
|
|
|
|
|
*
|
|
|
|
|
* This hook may be used to modify plugin properties after they have been
|
|
|
|
|
* specified by other modules.
|
|
|
|
|
*
|
|
|
|
|
* @param array $plugins
|
|
|
|
|
* An array of all the existing plugin definitions, passed by reference.
|
|
|
|
|
*
|
|
|
|
|
* @see \Drupal\views\Plugin\ViewsPluginManager
|
|
|
|
|
*/
|
|
|
|
|
function hook_views_plugins_query_alter(array &$plugins) {
|
|
|
|
|
// Print out all query plugin names for debugging purposes.
|
|
|
|
|
debug($plugins);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Modify the list of available views row plugins.
|
|
|
|
|
*
|
|
|
|
|
* This hook may be used to modify plugin properties after they have been
|
|
|
|
|
* specified by other modules.
|
|
|
|
|
*
|
|
|
|
|
* @param array $plugins
|
|
|
|
|
* An array of all the existing plugin definitions, passed by reference.
|
|
|
|
|
*
|
|
|
|
|
* @see \Drupal\views\Plugin\ViewsPluginManager
|
|
|
|
|
*/
|
|
|
|
|
function hook_views_plugins_row_alter(array &$plugins) {
|
|
|
|
|
// Change the used class of a plugin.
|
|
|
|
|
$plugins['entity:node']['class'] = 'Drupal\node\Plugin\views\row\NodeRow';
|
|
|
|
|
$plugins['entity:node']['module'] = 'node';
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Modify the list of available views style plugins.
|
|
|
|
|
*
|
|
|
|
|
* This hook may be used to modify plugin properties after they have been
|
|
|
|
|
* specified by other modules.
|
|
|
|
|
*
|
|
|
|
|
* @param array $plugins
|
|
|
|
|
* An array of all the existing plugin definitions, passed by reference.
|
|
|
|
|
*
|
|
|
|
|
* @see \Drupal\views\Plugin\ViewsPluginManager
|
|
|
|
|
*/
|
|
|
|
|
function hook_views_plugins_style_alter(array &$plugins) {
|
|
|
|
|
// Change the theme hook of a plugin.
|
|
|
|
|
$plugins['html_list']['theme'] = 'custom_views_view_list';
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Modify the list of available views wizard plugins.
|
|
|
|
|
*
|
|
|
|
|
* This hook may be used to modify plugin properties after they have been
|
|
|
|
|
* specified by other modules.
|
|
|
|
|
*
|
|
|
|
|
* @param array $plugins
|
|
|
|
|
* An array of all the existing plugin definitions, passed by reference.
|
|
|
|
|
*
|
|
|
|
|
* @see \Drupal\views\Plugin\ViewsPluginManager
|
|
|
|
|
*/
|
|
|
|
|
function hook_views_plugins_wizard_alter(array &$plugins) {
|
|
|
|
|
// Change the title of a plugin.
|
|
|
|
|
$plugins['node_revision']['title'] = t('Node revision wizard');
|
|
|
|
|
}
|
|
|
|
|
|
2009-05-17 11:16:51 +00:00
|
|
|
|
/**
|
|
|
|
|
* @}
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @defgroup views_module_handlers Views module handlers
|
|
|
|
|
* @{
|
|
|
|
|
* Handlers exposed by various modules to Views.
|
|
|
|
|
* @}
|
|
|
|
|
*/
|
2013-06-09 12:35:39 +00:00
|
|
|
|
|