drupal - 如何使用 hook_menu 在 Drupal 中注册通配符 url?

标签 drupal hook-menu

我开始使用 Drupal,我真的很困惑如何创建一个 hook_menu 函数,该函数允许您注册具有 1 或 2 个不同值的 URL,这些值可以隐藏并且不会显示在面包屑中。

对此的任何帮助将不胜感激。甚至是一个例子。

最佳答案

不确定面包屑位,但我认为您正在路径中寻找通配符 (%) 和自动加载器通配符 (%mymodule_entity) 组件。

来自hook_menu()页...

Wildcards within paths also work with integer substitution. For example, your module could register path 'my-module/%/edit'. When path 'my-module/foo/edit' is requested, integer 1 will be replaced with 'foo' and passed to the callback function. Note that wildcards may not be used as the first component.

$items['my-module/%/edit'] = array(
  'page callback' => 'mymodule_abc_edit',
  'page arguments' => array(1),
);

Registered paths may also contain special "auto-loader" wildcard components in the form of '%mymodule_abc', where the '%' part means that this path component is a wildcard, and the 'mymodule_abc' part defines the prefix for a load function, which here would be named mymodule_abc_load().

$items['my-module/%mymodule_abc/edit'] = array(
  'page callback' => 'mymodule_abc_edit',
  'page arguments' => array(1),
);

关于drupal - 如何使用 hook_menu 在 Drupal 中注册通配符 url?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13783374/

相关文章:

php - 当有人发布到论坛主题时的 Drupal 电子邮件

Drupal Feeds 显示编码的 HTML 标记

Drupal:使用前端主题从管理员呈现 View

drupal - 如何创建自定义访问功能以在 Drupal 中编辑节点类型?

drupal-7 - 如何避免用户路径中出现 Drupal 7 用户 ID?

php - 如何从我的自定义 Drupal 7 模块添加菜单项

css - 修复有问题的响应式 CSS Zen 子主题

Drupal 7 : Add Item to Admin Toolbar/Menu Programmatically

redirect - 德鲁帕尔 6 : How can i add a link to a hook_menu()?