问题标签 [drupal-hooks]

For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.

0 投票
1 回答
754 浏览

php - 如何在 hook_form_alter 上添加权重

我的模块中有一个 hook_form_alter,但另一个模块 workbench_access 也有一个 hook_form_alter,我需要在 hook_form_alter 之前调用它。如何增加我的 hook_form_alter 的重量?

0 投票
1 回答
1274 浏览

validation - Drupal file_validate_extensions 用于使用 hook_form_alter 的文件附件扩展

我使用名为 form_mods_form_alter 的函数构建了一个更改表单的模块。我只想允许 jpg、jpeg、png 文件类型。我所拥有的没有验证。它允许 gif,我不想允许 gif。

这是我得到的 print_r($form);

0 投票
1 回答
62 浏览

php - 仅在特定的 content_type 节点创建时加载 JS

drupal_add_jsDrupal 6.只有在创建特定时才执行的正确方法content_type是什么?

我有一些 jQuery 代码只需要执行来控制特定 content_type 创建中的一些表单元素。

我已经有一个模块,它的名称与 content_type 不同。这是一个问题吗?我还能挂在表格上吗?如果是这样,生成特定钩子的正确方法是node/add/content_type什么?

编辑:这仅用于创建,而不是视图。

编辑2:目前不工作的代码:文件:testmod.module

0 投票
1 回答
161 浏览

drupal - Drupal hook_menu_alter 系统错误

使用以下代码:

我收到以下错误:

警告:第 2011 行的 /var/www/vhosts/mysite.co.uk/httpdocs/modules/node/node.module 中的 node_access() 缺少参数 1。

该代码实际上可以工作并且可以执行我需要它执行的操作,但是该错误与我有关并且使我的站点用户感到困惑。

我不确定问题是什么或如何解决它。任何人都可以提供一些帮助吗?

0 投票
2 回答
182 浏览

drupal - hook_menu_alter() 响应不一致

此代码片段响应用户#1,但不响应其他登录或匿名用户:

我究竟做错了什么?

0 投票
1 回答
321 浏览

drupal - 为菜单创建模板文件

我想为菜单创建一个模板文件,我正在尝试这样的事情:

我在 mymainmenu.tpl.php 中编辑了主菜单的 HTML,但这段代码不起作用。为什么?

0 投票
2 回答
1326 浏览

php - Where to implement hook_search_info & _execute in order to force a language filter onto search results?

At the moment I am trying to force "current language" onto the list of the options passed into node_search_execute. Unfortunately I'm having trouble finding the right place to put the function hooks. Perhaps I am missing something simple.

I've got myself down to two basic possibilities for how this should be implemented.

(1) Implement hook_search_info and hook_search_execute

In this case, I'd copy the code from node_search_execute and add a line to it that adds "AND Language = '$current_language'" to the search query.

In my theme folder I've tried adding the functions mythemename_search_info and mythemename_search_execute - but they do not execute. When run.

In this example - I'd just hope to get "no results" so I could be sure the override was running, then I'd implement the full search functionality.

(2) Implement hook_search_preprocess()

I also tried mythemename_search_preprocess()

But again, I don't get the expected results (a white page with a bit of text on it)

So whatever I'm doing, these search hooks are not getting detected.

What's missing? Do they perhaps have to be in a module?

0 投票
1 回答
957 浏览

drupal - Drupal 6 hook_menu 带有来自 l() 的查询字符串

[Drupal 6] 我的预处理功能是

我的 hook_menu 是

和我的 delete_all_blogs()

我的用户可以像这样查看他们的个人资料 www.mysite.com/users/barack-obama

我的钩子似乎不起作用。url 中使用的 % 可能有错误。我不知道如何通用地使用它才能正常工作。

0 投票
1 回答
882 浏览

drupal - 如何防止在 Drupal 7 中修改和查看用户配置文件?

我想阻止特定用户(或用户组)在 Drupal 7 中修改其配置文件。这意味着当用户即将显示和更改其配置文件时,我想在事件上挂钩一些功能。

最好的解决方案是如果他甚至看不到他的个人资料,但我并不是要通过默默无闻来保护(隐藏链接),因为 drupalpage.com/user/X 将始终有效。

我怎样才能做到这一点?

PS:也许有什么模块可以不用编码就能达到目的?

0 投票
1 回答
507 浏览

drupal-6 - drupal 6:为用户帐户注册表写入 2 个不同的表

当用户在创建标准 Drupal 帐户时点击提交按钮时,如何将自定义字段值 $form['site_select'] 传递给我的案例“插入”,以便我可以将其写入“another_table”。用户名和密码等常规用户数据需要继续写入默认的“用户”表。

问:为什么不像往常一样让 Drupal 序列化并将您的数据保存到 'data' 字段中的 'users' 表中?

答:因为我希望能够在另一个 Drupal 表单中进行 AJAX 化和使用自动完成功能,以及在 MySQL 中查询特定的自定义字段。MySQL 无法序列化/反序列化。例如,“SELECT DISTINCT site_name FROM another_table”