drupal - 将自定义选项卡添加到用户个人资料页面 Drupal 7

标签 drupal drupal-7

我正在尝试在我的 Drupal 7 站点上的 mysite.com/user 上的用户帐户页面中添加两个新选项卡。我想添加指向添加照片节点/添加/照片和添加视频节点/添加/视频的链接,但我的模块 user_menu_add 的以下代码对我不起作用:

function user_menu_add_menu() {

$items['node/add/photos'] = array(
    'title' => t('Add Photos'),
    'page callback' => 'user_menu_add',
    'page arguments' => array(1),
    'access callback' => TRUE,
    'access arguments' => array('access user menu add'),
    'type' => MENU_LOCAL_TASK,
);

return $items;

}

我引用的一个例子是here有效,但仅适用于“/user”子目录下的链接
function my_module_menu() {

$items['user/%user/funky'] = array(
    'title' => t('Funky Button'),
    'page callback' => 'my_module_funky',
    'page arguments' => array(1),
    'access callback' => TRUE,
    'access arguments' => array('access funky button'),
    'type' => MENU_LOCAL_TASK,
);

return $items;

}

Current User Tabs

最佳答案

您可以保留 node/add/photos菜单项原样。您需要保持与 user/%user/addphoto 相同的 URL 模式格式。为了使选项卡出现在用户个人资料页面上。但是,请尝试使用 drupal_goto() 在您的新菜单项中重定向到 node/add/photos页。

试试这个:

$items['user/%user/addphoto'] = array(
  'title' => t('Add Photos'),
  'page callback' => 'drupal_goto',
  'page arguments' => array('node/add/photos'),
  'access callback' => 'user_is_logged_in',
  'type' => MENU_LOCAL_TASK,
);

引用:
  • drupal_goto()
  • user_is_logged_in()
  • Drupal 7 menu system
  • 关于drupal - 将自定义选项卡添加到用户个人资料页面 Drupal 7,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15855641/

    相关文章:

    linux - Windows 生产服务器上的 Drupal 7 和 WordPress 3.8?

    php - Drupal 模块主题 - 默认 CSS?

    php - 摆脱 db_query() drupal 中的单引号

    mysql - 如何从 db_query 结果中排除未发布的节点?

    php - Azure 上的 Drupal update.php 抛出错误 "Could not connect to server"

    php - 多语言网站中的菜单 drupal

    php - 您应该采取哪些步骤来加速 SimpleTest?

    Drupal 7 新手问题 : Node Access Permissions = disabled?

    git - 使用 GitHub 作为托管 Drupal 站点的版本控制工具

    javascript - 除了 jQuery 之外,还有哪个 Javascript 库使用 $?