我开始使用 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/