2009-06-04 22 views
1

修改download_count模塊以包含有關下載文件的用戶的信息。想要在用戶的個人資料頁面上顯示此信息。定製模塊中的Drupal user_hook

下面的代碼:

function download_count_user($op, &$edit, &$account, $caterory = NULL) { 
    if ($op == 'view') 
    { 

    $result = db_query("SELECT filename FROM file_downloads_users WHERE user_id = %d", $account->uid); 

    while ($file_array = db_fetch_object($result)) { 
     $file_str .= $file->filename . '<br/>'; 
    } 

    $items['downloads'] = array(
    'title' => t('Files'), 
    'value' => $file_str, 
     'class' => 'member' 
    ); 
    return array(t('Downloads')=>$items);  
    } 

} 

不給我任何錯誤,但不顯示任何我的帳戶頁面上的任何內容。

回答

2

您不想修改模塊。 Drupal非常小心地構建,以避免必須破解核心或貢獻。除非你正在貢獻補丁。

正確的方法是構建您自己的自定義模塊來執行此操作(這將需要用戶下載模塊)並實現與您在此處執行的操作幾乎完全相同的操作。

  1. 功能越來越運行(啓用模塊,荷蘭國際集團的var_dump或krumo'ing導致輸出?緩存中清除)
  2. 你鍵入你的變量的方法是爲Drupal 5.x和下面。在D6中,您添加到$ account-> content。你使用的是哪個版本的drupal?

退房user_user()(在user.module):

$account->content['user_picture'] = array(
    '#value' => theme('user_picture', $account), 
    '#weight' => -10, 
); 
+0

我是6,我已經嘗試添加到$帳戶,沒有工作 – user87771 2009-06-04 20:09:07

0
$account->content['summary']['file_downloads'] = array(
     '#type' => 'user_profile_item', 
     '#title' => t('File Downloads'), 
     '#value' => $file_str, 
     '#weight' => 1 
    );