开发者

Can anyone point me to a reference for the Drupal $account->content array?

I've been digging around all morning and I can't find any reference that defines the account object.

In particular, I want to modify another drupal admin's user hook() function to change the way it works. Currently, it comes out as dt/dd pairs without any css classes or custom styles, and I need to be able to theme the content.

  function acidfree_user($op, &$edit, &$account, $category = NULL) {
    if ($op == 'view') {
    //Pachkov.Sergey.START - MODIFIED BY MHEINZ
      $result = db_query("SELECT nid, title FROM node WHERE nid IN (SELECT nid FROM node WHERE uid=%d 
                         AND type='acidfree') ORDER BY nid desc", $account->uid);

      $i=0;
      $account->content['acidfree-albums'] = array(
        '#type' => 'user_profile_category',
        '#title' => t('Photo albums'),
      );
      while ($item = db_fetch_array($result)) {
        $title_node = $item['title'];
        $nid = $item['nid'];
        $account->content['acidfree-albums'][$i] = array(
                '#title' => t(' '),
                '#value' =&开发者_Python百科gt; l($title_node, "node/{$nid}"),
                '#class' => 'acidfree-albums',
                '#type' => 'user_profile_item',
        );
        $i++;
      }
    }
    //Pachkov.Sergey.END - MODIFIED BY MHEINZ
  }


The dt/dd used to display the $account->content array you see in hook_user come from the user-profile-item.tpl.php template. Using template_preprocess_user_profile_item in your modules or theme, you can add attributes for these dt/dd.

If you need to change one of the items in the $account->content array, you should use hook_profile_alter:

function MODULE_profile_alter(&$account) {
  $account->content['acidfree-albums']['#title'] = t('Awesome photos!');
}


The best reference you can get is

print_r($account->content);

and to see the trace to your current location (to see where the object is set) you could use

debug_print_backtrace();
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜