如何在 Drupal 7 中向用户个人资料页面添加内容?

发布于 2024-12-21 06:04:30 字数 1169 浏览 6 评论 0原文

我正在尝试在 Drupal 7 中的用户配置文件中添加几个部分:

< /code>

我添加了三个新部分,但问题是,虽然我使用相同的方式添加这三个部分,但只有其中一个被渲染为上面 div 的子级,而其他两个则被渲染作为兄弟姐妹。我做错了什么?

这就是我创建内容的方式:

function plan_user_user_view($account) {    
//Create the markup for the events region
$account->content['events'] = array(
  '#type' => 'user_profile_item',
  '#theme' => 'events',
  '#events' => $events);

 //Create the region for the venues
  $account->content['venues'] = array(
   '#type' => 'user_profile_item',
   '#theme' =>'venues',
   '#userid' => $user->uid,
   '#venues' => $venues);

  //Create the region for creating an event
  $account->content['creator'] = array(
    '#prefix' => '<div class="user-event-item" id="quick-event-creator">',
    '#suffix' => '</div>',
    '#type' => 'user_profile_item',
    '#title' => t('QUICK EVENT CREATOR'),
    '#markup' => drupal_render(drupal_get_form('event_creation')));
 }

另外,是否有更好的方法来创建最后一段内容?另外两个在模板文件中看起来不错,但最后一个因为它是一种表单,我想知道是否有更好的方法来做到这一点。

谢谢,

I'm trying to add a couple of sections onto the user profile in Drupal 7 under:

<div class="profile" typeof="sioc:UserAccount" about="/drupal/user/1">

I'm adding three new sections, but the problem is that, although I am using the same way to add the three sections, only one of them is rendered as a child of the div above, while the other two are rendered as siblings. What am I doing wrong?

This is how I'm creating the content:

function plan_user_user_view($account) {    
//Create the markup for the events region
$account->content['events'] = array(
  '#type' => 'user_profile_item',
  '#theme' => 'events',
  '#events' => $events);

 //Create the region for the venues
  $account->content['venues'] = array(
   '#type' => 'user_profile_item',
   '#theme' =>'venues',
   '#userid' => $user->uid,
   '#venues' => $venues);

  //Create the region for creating an event
  $account->content['creator'] = array(
    '#prefix' => '<div class="user-event-item" id="quick-event-creator">',
    '#suffix' => '</div>',
    '#type' => 'user_profile_item',
    '#title' => t('QUICK EVENT CREATOR'),
    '#markup' => drupal_render(drupal_get_form('event_creation')));
 }

Also, is there a better way to create that last piece of content there? The other two seem fine in a template file but the last one since it's a form I was wondering if there are better ways of doing that.

Thanks,

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

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

发布评论

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

评论(2

宫墨修音 2024-12-28 06:04:30

也许你应该看看这个项目profil2,它是 Drupal 6 的 content_profil 的后继者。有了它您将能够将信息添加到用户个人资料中,如果您想自己编写自定义字段,那么这应该是一个很好的阅读起点。

最好的。

Maybe you should have a look on this project profil2 which is the successor of content_profil for Drupal 6. With it you will be able to add informations onto users profils and if you want to code your custom fields by yourself it should be a good starting point to read.

Best.

白日梦 2024-12-28 06:04:30

这个怎么样:

// Create the category.
$account->content['mymodule'] = array(
    '#type' => 'user_profile_category',
    '#title' => t('My module content'),
);

// Create first item (child).
$account->content['mymodule']['events'] = array(
    '#type' => 'user_profile_item',
    '#title' => t('Events'),
    '#markup' => t('Whatever'),
);

// Create second item (child).
$account->content['mymodule']['venues'] = array(
    '#type' => 'user_profile_item',
    '#title' => t('Venues'),
    '#markup' => t('Whatever'),
);

等等。最重要的是,user_profile_item 项应该是 user_profile_category 项的子项。

How about this:

// Create the category.
$account->content['mymodule'] = array(
    '#type' => 'user_profile_category',
    '#title' => t('My module content'),
);

// Create first item (child).
$account->content['mymodule']['events'] = array(
    '#type' => 'user_profile_item',
    '#title' => t('Events'),
    '#markup' => t('Whatever'),
);

// Create second item (child).
$account->content['mymodule']['venues'] = array(
    '#type' => 'user_profile_item',
    '#title' => t('Venues'),
    '#markup' => t('Whatever'),
);

and so on. The bottom line is that user_profile_item items should be children of a user_profile_category item.

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