Ala*_*orm 6 drupal drupal-7 drupal-routes
如何在Drupal中创建一个不会自动呈现导航链接的新路径/菜单?
我正在尝试在Drupal中创建一个没有显示在导航菜单中的简单页面回调.
我有一个名为的模块helloworld.
该.module文件包含以下内容
function _helloword_page_callback()
{
return array('#markup'=>'The quick brown fox says hello, and the lazy dogs thanks you
for following conventions.');
}
function helloworld_menu()
{
$items['helloworld'] = array(
'title' => 'Hello World',
'page callback' => '_helloword_page_callback',
'access arguments' => array('content'),
'type' => MENU_CALLBACK
);
return $items;
}
Run Code Online (Sandbox Code Playgroud)
这成功地在网站上公开了一个URL
http://example.drupal.com/helloworld
Run Code Online (Sandbox Code Playgroud)
但是,我仍然在左手(Bartik)导航菜单中获得了一个链接,尽管使用了
'type' => MENU_CALLBACK
Run Code Online (Sandbox Code Playgroud)
那么,为什么这不起作用?我正确配置菜单项吗?更可能的问题:我如何误解菜单类型常量/系统的使用?是否有其他缓存来清除它
drush cc all
Run Code Online (Sandbox Code Playgroud)
会不会照顾?我可以采取哪些其他步骤进行调试?
一定有其他错误(也许你忘了清除缓存?)因为即使使用Bartik,它也可以按预期工作.在该示例中,导航中仅显示"Hello 2":
function helloworld_menu(){
return array(
'hello1' => array(
'title' => 'Hello 1',
'page callback' => 'helloworld_page_callback',
'access arguments' => array('content'),
'type' => MENU_CALLBACK
),
'hello2' => array(
'title' => 'Hello 2',
'page callback' => 'helloworld_page_callback',
'access arguments' => array('content')
)
);
}
function helloworld_page_callback(){
return array('#markup'=>'The quick brown fox says hello, and the lazy dogs thanks you for following conventions.');
}
Run Code Online (Sandbox Code Playgroud)
顺便说一句,你的snipplet中有一个拼写错误(helloroute_menu应该命名helloworld_menu),但我认为这是由于在StackOverflow上发布之前的代码简化.