6.x的-3.X文档/ docs.php views_hooks
7.x的-3.X views.api.php views_hooks
可以由其他模块实现的Hook,以实现Views API。
文件
./
views.api.php,线路285
描述Views模块提供的钩子。
欢迎各位兄弟 发布技术文章
这里的技术是共享的
http://api.drupal.org/api/views/views.api.php/7 API
https://api.drupal.org/api/views/docs!docs.php/group/views_hooks/6
http://drupal.org/documentation/modules/views DOcument
hook_views_data
hook_views_data_alter(&$data) 把你自己模块中的数据字段加进views,过滤表结构
hook_views_plugins
hook_views_plugins_alter
hook_views_api 用来告诉views从哪个目录去寻找MODULENAME.views.inc的文件,注册一个View API信息
hook_views_default_views
hook_views_default_views_alter
hook_views_pre_view
hook_views_pre_build
hook_views_post_build 查询现在完全建成,但是还没有运行db_rewrite_sql
hook_views_pre_execute
hook_views_post_execute 此Hook是查询处理后. 到pre_render()前提供
hook_views_pre_render 应该是执行 sql语句前执行的代码
hook_views_post_render 输出所有渲染的数据
hook_views_query_alter(&$view, &$query) 修改views生成的sql
hook_views_preview_info_alter
hook_views_ui_display_top_links_alter
hook_views_ajax_data_alter 它允许你修改views的ajax请求
hook_views_invalidate_cache
来自 http://www.xiukun.me/views-hook/
Hooks that can be implemented by other modules in order to implement the Views API.
Functions | |
hook_views_data () | |
Describe table structure to Views. | |
hook_views_plugins () | |
The full documentation for this hook is now in the advanced help. | |
hook_views_handlers () | |
Register handler, file and parent information so that handlers can be loaded only on request. | |
hook_views_api () | |
Register View API information. | |
hook_views_default_views () | |
This hook allows modules to provide their own views which can either be used as-is or as a "starter" for users to build from. | |
hook_views_default_views_alter (&$views) | |
This hook is called right before all default views are cached to the database. | |
hook_views_convert () | |
Stub hook documentation. | |
hook_views_query_substitutions () | |
Stub hook documentation. | |
hook_views_pre_view (&$view, &$display_id, &$args) | |
This hook is called at the very beginning of views processing, before anything is done. | |
hook_views_pre_build (&$view) | |
This hook is called right before the build process, but after displays are attached and the display performs its pre_execute phase. | |
hook_views_pre_execute (&$view) | |
This hook is called right before the execute process. | |
hook_views_pre_render (&$view) | |
This hook is called right before the render process. | |
hook_views_post_render (&$view, &$output, &$cache) | |
Post process any rendered data. | |
hook_views_query_alter (&$view, &$query) | |
Stub hook documentation. | |
hook_views_admin_links_alter (&$links, $view) | |
This hook should be placed in MODULENAME.views.inc and it will be auto-loaded. | |
hook_views_preview_info_alter (&$rows, $view) | |
This hook should be placed in MODULENAME.views.inc and it will be auto-loaded. |
hook_views_admin_links_alter | ( | &$ | links, | |
$ | view | |||
) |
This hook should be placed in MODULENAME.views.inc and it will be auto-loaded.
This must either be in the same directory as the .module file or in a subdirectory named 'includes'.
Alter the links that appear over a view. They are in a format suitable for theme('links').
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.
See also:
theme_links
hook_views_api | ( | ) |
Register View API information.
This is required for your module to have its include files loaded; for example, when implementing hook_views_default_views().
Returns:
An array with the following possible keys:
api: (required) The version of the Views API the module implements.
path: (optional) If includes are stored somewhere other than within the root module directory or a subdirectory called includes, specify its path here.
hook_views_convert | ( | ) |
hook_views_data | ( | ) |
Describe table structure to Views.
This hook should be placed in MODULENAME.views.inc and it will be auto-loaded. This must either be in the same directory as the .module file or in a subdirectory named 'includes'.
The full documentation for this hook is in the advanced help. http://views-help.doc.logrus.com/help/views/api-tables
Definition at line 74 of file docs.php.
hook_views_default_views | ( | ) |
This hook allows modules to provide their own views which can either be used as-is or as a "starter" for users to build from.
This hook should be placed in MODULENAME.views_default.inc and it will be auto-loaded. This must either be in the same directory as the .module file or in a subdirectory named 'includes'.
The $view->disabled boolean flag indicates whether the View should be enabled or disabled by default.
Returns:
An associative array containing the structures of views, as generated from the Export tab, keyed by the view name. A best practice is to go through and add t() to all title and label strings, with the exception of menu strings.
Definition at line 268 of file docs.php.
hook_views_default_views_alter | ( | &$ | views | ) |
This hook is called right before all default views are cached to the database.
It takes a keyed array of views by reference.
hook_views_handlers | ( | ) |
hook_views_plugins | ( | ) |
The full documentation for this hook is now in the advanced help.
This hook should be placed in MODULENAME.views.inc and it will be auto-loaded. This must either be in the same directory as the .module file or in a subdirectory named 'includes'.
This is a stub list as a reminder that this needs to be doc'd and is not used in views anywhere so might not be remembered when this is formally documented:
style: 'even empty'
hook_views_post_render | ( | &$ | view, | |
&$ | output, | |||
&$ | cache | |||
) |
Post process any rendered data.
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 comment based tokens, and then the post process can replace those tokens.
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:
And then in the post render, create an array with the text that should go there:
strtr($output, array('', 'output for FIELD of nid 1');
All of the cached result data will be available in $view->result, as well, so all ids used in the query should be discoverable.
This hook can be utilized by themes.
hook_views_pre_build | ( | &$ | view | ) |
This hook is called right before the build process, but after displays are attached and the display performs its pre_execute phase.
Adding output to the view cam be accomplished by placing text on $view->attachment_before and $view->attachment_after
hook_views_pre_execute | ( | &$ | view | ) |
This hook is called right before the execute process.
The query is now fully built, but it has not yet been run through db_rewrite_sql.
Adding output to the view cam be accomplished by placing text on $view->attachment_before and $view->attachment_after
hook_views_pre_render | ( | &$ | view | ) |
This hook is called right before the render process.
The query has been executed, and the pre_render() phase has already happened for handlers, so all data should be available.
Adding output to the view cam be accomplished by placing text on $view->attachment_before and $view->attachment_after
This hook can be utilized by themes.
hook_views_pre_view | ( | &$ | view, | |
&$ | display_id, | |||
&$ | args | |||
) |
hook_views_preview_info_alter | ( | &$ | rows, | |
$ | view | |||
) |
This hook should be placed in MODULENAME.views.inc and it will be auto-loaded.
This must either be in the same directory as the .module file or in a subdirectory named 'includes'.
Alter the rows that appear with a view, which includes path and query information. The rows are suitable for theme('table').
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.
See also:
theme_table
hook_views_query_alter | ( | &$ | view, | |
&$ | query | |||
) |
hook_views_query_substitutions | ( | ) |
来自 http://views.doc.logrus.com/group__views__hooks.html
6.x的-3.X文档/ docs.php views_hooks
7.x的-3.X views.api.php views_hooks
可以由其他模块实现的Hook,以实现Views API。
./
views.api.php,线路285
描述Views模块提供的钩子。
注释
挂钩执行顺序
hook_views_pre_view
hook_views_pre_build
hook_views_post_build
hook_views_pre_execute
hook_views_post_execute
hook_views_pre_render
hook_views_post_render
登录或注册后发表评论
谢谢你!
感谢您的执行顺序; 这是一个方便的参考。
登录或注册后发表评论
顺序是很大的帮助..!
感谢@Alex,这个序列节省了很多时间..!
登录或注册后发表评论
我讨厌+1讯息...
...但是,我的上帝人,为什么不能更多的人/模块/维护者这样做!谢谢!
登录或注册后发表评论
@ alex.designworks - 一个大
@ alex.designworks - 非常感谢给予执行的顺序!
登录或注册后发表评论
另一个真正有用的指南
:另一种真正有用的指导挂钩的执行顺序可以在此演示文稿中找到的http://colorado2011.drupalcamp.org/sites/default/files/slides/Using_View ...
来自 https://api.drupal.org/api/views/views.api.php/group/views_hooks/7.x-3.x