Drupal hook_views_post_execute not getting called(Drupal hook_views_post_execute 没有被调用)
问题描述
我正在尝试连接 Drupal 7 中的 hook_views_post_execute
事件,我的名为 foo
的模块位于 sites/default/modules/features/foo
.
I'm trying to hook into the hook_views_post_execute
event in Drupal 7, my module called foo
is located in sites/default/modules/features/foo
.
我的 foo.module
文件包含对 hook_views_api
函数的定义,定义如下:
My foo.module
file contains a definition for the hook_views_api
function, defined like this:
function foo_views_api() {
return array("version" => 3.0);
}
这个函数被调用了,但我的 hook_views_post_execute
实现没有,它是这样定义的(在同一个 foo.module
文件中):
This function gets called, but my implementation of the hook_views_post_execute
does not, it's defined (in the same foo.module
file) like this:
function foo_views_post_execute(&$view) {
$seen_rows = array();
$newResults = array();
for($i = 0; $i < count($view->result); ++$i) {
if (!in_array($view->result[$i]->nid, $seen_rows)) {
$newResults[] = $view->results[$i];
}
$seen_rows[] = $view->result[$i]->nid;
}
$view->result = $newResults;
}
我已经浏览了 drupal API/hooks 文档,在谷歌上搜索并阅读了我能找到的每篇博文.我只是无法让它工作.钩子不会被调用.我假设我做了一些简单的错误,因为我通常不是 Drupal 开发人员或 PHP 开发人员.
I've been over the drupal API/hooks documentation, googled and read every blog post I've been able to find. I just can't get it to work. The hook does not get called. I'm assuming I've done something simple wrong since I'm not a drupal developer or PHP developer normally.
推荐答案
该视图可能已被缓存,因此它不会通过该函数.
The view has probably been cached so it doesn't go through that function.
转到左上角并清除缓存,您应该会看到结果.
Go to the top left and clear the cache and you should see the result.
这篇关于Drupal hook_views_post_execute 没有被调用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:Drupal hook_views_post_execute 没有被调用


- 如何从数据库中获取数据以在 laravel 中查看页面? 2022-01-01
- 覆盖 Magento 社区模块控制器的问题 2022-01-01
- PHP - if 语句中的倒序 2021-01-01
- Laravel 5:Model.php 中的 MassAssignmentException 2021-01-01
- 如何在 Symfony2 中正确使用 webSockets 2021-01-01
- 使用 GD 和 libjpeg 支持编译 PHP 2022-01-01
- Oracle 即时客户端 DYLD_LIBRARY_PATH 错误 2022-01-01
- openssl_digest vs hash vs hash_hmac?盐与盐的区别HMAC? 2022-01-01
- 如何使用 Google API 在团队云端硬盘中创建文件夹? 2022-01-01
- PHP foreach() 与数组中的数组? 2022-01-01