Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
D
drupal
Manage
Activity
Members
Labels
Plan
Wiki
Custom issue tracker
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Model registry
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
project
drupal
Commits
0e35c129
Commit
0e35c129
authored
12 years ago
by
Jess
Committed by
Tim Plunkett
12 years ago
Browse files
Options
Downloads
Patches
Plain Diff
Issue
#1808756
by xjm: Update docs for a couple alter hooks.
parent
4c379097
No related branches found
Branches containing commit
No related tags found
Tags containing commit
2 merge requests
!7452
Issue #1797438. HTML5 validation is preventing form submit and not fully...
,
!789
Issue #3210310: Adjust Database API to remove deprecated Drupal 9 code in Drupal 10
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
views.api.php
+12
-21
12 additions, 21 deletions
views.api.php
with
12 additions
and
21 deletions
views.api.php
+
12
−
21
View file @
0e35c129
...
@@ -504,20 +504,17 @@ function hook_views_post_render(ViewExecutable &$view, &$output, CacheBackendInt
...
@@ -504,20 +504,17 @@ function hook_views_post_render(ViewExecutable &$view, &$output, CacheBackendInt
}
}
/**
/**
* Alter the query before
executing the query
.
* Alter the query before
it is executed
.
*
*
* This hook should be placed in MODULENAME.views.inc and it will be
* @param Drupal\views\ViewExecutable $view
* 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.
*
* @param $view
* The view object about to be processed.
* The view object about to be processed.
* @param $query
* @param QueryPluginBase $query
* An object describing the query.
* The query plugin object for the query.
*
* @see hook_views_query_substitutions()
* @see hook_views_query_substitutions()
* @see Drupal\views\Plugin\views\query\Sql
*/
*/
function
hook_views_query_alter
(
&
$view
,
&
$query
)
{
function
hook_views_query_alter
(
ViewExecutable
&
$view
,
QueryPluginBase
&
$query
)
{
// (Example assuming a view with an exposed filter on node title.)
// (Example assuming a view with an exposed filter on node title.)
// If the input for the title filter is a positive integer, filter against
// If the input for the title filter is a positive integer, filter against
// node ID instead of node title.
// node ID instead of node title.
...
@@ -543,25 +540,19 @@ function hook_views_query_alter(&$view, &$query) {
...
@@ -543,25 +540,19 @@ function hook_views_query_alter(&$view, &$query) {
* Alter the information box that (optionally) appears with a view preview,
* Alter the information box that (optionally) appears with a view preview,
* including query and performance statistics.
* including query and performance statistics.
*
*
* This hook should be placed in MODULENAME.views.inc and it will be
* @param array $rows
* 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.
*
* Warning: $view is not a reference in PHP4 and cannot be modified here. But it
* IS a reference in PHP5, and can be modified. Please be careful with it.
*
* @param $rows
* An associative array with two keys:
* An associative array with two keys:
* - query: An array of rows suitable for theme('table'), containing
* - query: An array of rows suitable for theme('table'), containing
* information about the query and the display title and path.
* information about the query and the display title and path.
* - statistics: An array of rows suitable for theme('table'), containing
* - statistics: An array of rows suitable for theme('table'), containing
* performance statistics.
* performance statistics.
* @param $view
* @param
Drupal\views\ViewExecutable
$view
* The view object.
* The view object.
*
* @see Drupal\views_ui\ViewUI
* @see theme_table()
* @see theme_table()
*/
*/
function
hook_views_preview_info_alter
(
&
$rows
,
$view
)
{
function
hook_views_preview_info_alter
(
array
&
$rows
,
ViewExecutable
$view
)
{
// Adds information about the tables being queried by the view to the query
// Adds information about the tables being queried by the view to the query
// part of the info box.
// part of the info box.
$rows
[
'query'
][]
=
array
(
$rows
[
'query'
][]
=
array
(
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment