在个人资料中添加选项卡

发布于 2024-09-14 06:43:00 字数 349 浏览 1 评论 0原文

如何将选项卡添加到我的个人资料 (/users/my-name) 中? 我使用了这个功能,但没有显示任何内容:

function tpzclassified_menu() {
  $items['user/%user/kleinanzeigen'] = array(
    'title' => t('Meine Kleinanzeigen'),
    'page arguments' => array(1),
    'access callback' => TRUE,
    'type' => MENU_LOCAL_TASK,
  );

  return $items;
}

How can I add a tab into my personal profile (/users/my-name)?
I used this function, but nothuing shows up:

function tpzclassified_menu() {
  $items['user/%user/kleinanzeigen'] = array(
    'title' => t('Meine Kleinanzeigen'),
    'page arguments' => array(1),
    'access callback' => TRUE,
    'type' => MENU_LOCAL_TASK,
  );

  return $items;
}

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

情归归情 2024-09-21 06:43:00

您缺少页面回调属性:

function tpzclassified_menu() {
  $items['user/%user/kleinanzeigen'] = array(
    'title' => t('Meine Kleinanzeigen'),
    'page callback' => 'tpzclassified_kleinanzeigen',
    'page arguments' => array(1),
    'access callback' => 'user_view_access',
    'access arguments' => array(1),
    'type' => MENU_LOCAL_TASK,
  ); 

  return $items; 
}

function tpzclassified_kleinanzeigen($account) {
  return 'This is the Meine Kleinanzeigen page';
}

tpzclassified_kleinanzeigen替换为生成页面的函数名称。

另外,切勿使用 'access callback' =>正确:这是一个巨大的安全漏洞。我已将其更改为使用 user_view_access(),它会检查是否允许用户查看 %user 的个人资料。如果您想检查是否允许用户编辑 %user 的个人资料,您可以使用 user_edit_access()

You're missing the page callback property:

function tpzclassified_menu() {
  $items['user/%user/kleinanzeigen'] = array(
    'title' => t('Meine Kleinanzeigen'),
    'page callback' => 'tpzclassified_kleinanzeigen',
    'page arguments' => array(1),
    'access callback' => 'user_view_access',
    'access arguments' => array(1),
    'type' => MENU_LOCAL_TASK,
  ); 

  return $items; 
}

function tpzclassified_kleinanzeigen($account) {
  return 'This is the Meine Kleinanzeigen page';
}

Replace tpzclassified_kleinanzeigen with the function name that generates the page.

Also, never use 'access callback' => TRUE: it's a huge security hole. I've changed that to use user_view_access(), which checks to the see if the user is allowed to view %user's profile. You could use user_edit_access() if you wanted to check to see if a user is allowed to edit %user's profile.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文