Drupal 7 drupal菜单回调钩子未调用函数
我正在使用Drupal7。 我有一个指向href=“/mod/filter/1”的链接 然后是回调函数Drupal 7 drupal菜单回调钩子未调用函数,drupal-7,hook,Drupal 7,Hook,我正在使用Drupal7。 我有一个指向href=“/mod/filter/1”的链接 然后是回调函数 function mod_remove_filter_function($arg){ dsm('call back filter'); drupal_goto('/res/search'); } 对我来说,这应该行得通,这是我第一次使用菜单钩子,但根据给出的文档,这看起来应该行得通 你知道为什么它不起作用吗 function mod_menu () { $menu
function mod_remove_filter_function($arg){
dsm('call back filter');
drupal_goto('/res/search');
}
对我来说,这应该行得通,这是我第一次使用菜单钩子,但根据给出的文档,这看起来应该行得通
你知道为什么它不起作用吗
function mod_menu () {
$menu = array(
'mod/filter/%' => array (
"title" => "Bare HTML for use in ajax.",
"page callback" => "mod_remove_filter_function",
"page arguments" => array(1),
"type" => MENU_CALLBACK,
)
);
return $menu;
}
钩子是完美的。问题可能在回调函数中
dsm函数需要devel模块,如果您使用的是drupal_goto('/res/search');首先检查“/res/search”路径
:)
下面是我如何在自定义模块中使用hook_菜单
$menu['mod/filter/%'] = array(
'title'=>t('look this is title'),
'page callback' => 'mod_remove_filter_function',
'access callback' => 'user_access',
'access arguments' => array('access_contents'),
'type' => MENU_NORMAL_ITEM,
);
不要在菜单项中使用t()函数。通过defualt,drupal将标题字符串传递到函数t()。您可以通过在菜单项数组中设置新的“标题回调”来更改该行为
:)
$menu['mod/filter/%'] = array(
'title'=>t('look this is title'),
'page callback' => 'mod_remove_filter_function',
'access callback' => 'user_access',
'access arguments' => array('access_contents'),
'type' => MENU_NORMAL_ITEM,
);