Community Documentation

ARCHIVE: Other hooks

Last updated March 26, 2011. Created by jscheel on November 24, 2006.
Edited by linclark, merlinofchaos. Log in to edit this page.

In addition to the hooks that feed information to Views, covered in the previous sections, Views also provides hooks that allow your module to modify the view in some fashion.

hook_views_query_alter(&$query, &$view, $summary, $level)
Allows a module to alter a query just before it is created. Note that this is only called when the query is actually generated, not necessarily every time the view is run -- this is because some queries may be cached.

Parameters

&$query The fully populated $query object.
&$view The view the query is being built for.
$summary If true, $view is in summary mode.
$level If in summary mode, $level is the index of the argument that is powering the summary. See the arguments section for more information.

Return value

None.

hook_views_query_substitutions($view)
Allow string substitutions just prior to the query being run. This is used by Views to embed things such as current time or current user into the query as special strings; just prior to the query being run, the proper values are substituted in. This is performed every time a query is run.

Parameters

&$view The view the query is being run for.

Return value

An array of key-value substitutions. The key is the text to replace, and the value is the text to insert.

hook_views_pre_query(&$view)
Called just before a query begins to be built for every view. This is called even if the query is cached. If the query is cached, it will be available on $view->query

Parameters

&$view The view the query is being run for.

Return value

A string that will be prepended to the view.

hook_views_pre_view(&$view, &$items)
Called just before a view is themed. This is called even if the query is cached.

Parameters

&$view The view being themed.
&$items The items returned by the view.

Return value

A string that will be prepended to the view.

hook_views_post_view(&$view, &$items)
Called just after a view is themed. This is called even if the query is cached.

Parameters

&$view The view being themed.
&$items The items returned by the view.

Return value

A string that will be appended to the view.


About this page

Drupal version
Drupal 4.7.x, Drupal 5.x

Archive

Drupal’s online documentation is © 2000-2012 by the individual contributors and can be used in accordance with the Creative Commons License, Attribution-ShareAlike 2.0. PHP code is distributed under the GNU General Public License.
nobody click here