2011-07-19 9 views
0

Drupal 6とhook_user()に問題があります。私はユーザノードに新しいカテゴリを追加するモジュールを作成しました。それらの1つは「アドレス」です。私はこの新しいカテゴリを持っており、私は "My Account"でアクセスすることができます。 op "form"が呼び出されると、私は必要なすべてのアドレスを収集します。しかし私はそれらをテーマにする方法を見つけることができません。今は、テーブルにうまく配置される代わりに、いくつかのフィールドがページにダンプされています。私は "user-profile.tpl.php"を認識していますが、変更することはできません。他のモジュールがあるかもしれないので、それも変更します。Drupal 6:テーマはhook_user()のカテゴリ

誰もが、どのようにユーザーのカテゴリで素敵なテーマのテーブルを達成するためのアイデアを持っていますか?

よろしく Gewürzwiesel

答えて

0

使用のDrupal 6のhook_user 'ビュー' 操作。ドキュメントから: "view":ユーザーのアカウント情報が表示されています。モジュールは表示のためにカスタム追加をフォーマットし、$ account-> content配列に追加する必要があります。

+0

ここでの表示は問題ではありません。私は私のフォームを編集したい。したがって、 'view'操作は呼び出されません。 私はちょっとそれを逃した;) –

2
// hook_user 
function mymodule_user($op, &$edit, &$account, $category = NULL) { 
    switch ($op) { 
    case 'categories': 
    $output[] = array(
     'name' => 'new_category', 
     'title' => t('new_category'), 
    ); 
    case 'form': 
    if ($category == 'new_category') { 
     $form_state = array(); 
     $form = mymodule_new_category_form($form_state, $account); 
     return $form; 
    } 
    break; 
    } 
} 

function mymodule_new_category_form(&$form_state, $account) { 
    $form = array(); 

    $form['new_category'] = array(
    '#type' => 'fieldset', 
    '#title' => t('new_category'), 
    '#theme' => 'mymodule_new_category_form', 
); 
    $form['new_category']['text1'] = array(
    '#type' => 'textfield', 
    '#title' => t('text1'), 
); 
    $form['new_category']['text2'] = array(
    '#type' => 'textfield', 
    '#title' => t('text2'), 
); 
    $form['new_category']['text3'] = array(
    '#type' => 'textfield', 
    '#title' => t('text3'), 
); 

    return $form; 
} 

// hook_theme 
function mymodule_theme() { 
    return array(
    'mymodule_new_category_form' => array(
     'arguments' => array('form' => NULL), 
    ), 
); 
} 

function theme_mymodule_new_category_form($form) { 
    $rows = array(); 

    foreach (element_children($form) as $form_field_name) { 
    $description = $form[$form_field_name]['#description']; 
    $form[$form_field_name]['#description'] = ''; 

    $title = theme('form_element', $form[$form_field_name], ''); 
    $form[$form_field_name]['#description'] = $description; 
    $form[$form_field_name]['#title'] = ''; 
    $row = array(
     'data' => array(
     0 => array('data' => $title, 'class' => 'label_cell'), 
     1 => drupal_render($form[$form_field_name]) 
    ) 
    ); 
    $rows[] = $row; 
    } 

    $output = theme('table', array(), $rows); 
    $output .= drupal_render($form); 

    return $output; 
} 
関連する問題