开发者

Drupal adding external links to custom menus

开发者 https://www.devze.com 2023-04-04 18:51 出处:网络
I am trying to add a custom menu to Drupal 7 but it seems that I am not able to handle external links in hook_menu as they don\'t get inserted into the database. When I change the implementation to us

I am trying to add a custom menu to Drupal 7 but it seems that I am not able to handle external links in hook_menu as they don't get inserted into the database. When I change the implementation to use menu_link_save, internal menu items don't get saved in the m开发者_JS百科enu route table so they don't show up. Is there a way to implement a custom menu that will be displayed in the footer that contains both normal menu items and links to external websites?


hook_menu() is really only for internal paths by design and as such external paths don't belong in the menu_router table. There is a little trick you can do to make internal paths that you define immediately redirect to the external site, using drupal_goto() as your page callback:

$items['my_internal_path'] = array(
  'title' => 'Title',
  'type' => MENU_NORMAL_ITEM,
  'access arguments' => array('access content'),
  'page callback' => 'drupal_goto',
  'page arguments' => array('http://external-site.com/')
);

Hope that helps


This is not true, atleast not now.

You can add external items like this

$items['http://facebook.com/'] = array(
  'title' => t('Facebook'),
  'type' => MENU_NORMAL_ITEM,
  'access arguments' => array('access content'),
  'menu_name' => 'menu-footer'
);
0

精彩评论

暂无评论...
验证码 换一张
取 消