0

Drupal 6 と hook_user() に問題があります。ユーザーノードに新しいカテゴリを追加するモジュールを作成しました。その一つが「住所」です。この新しいカテゴリがあり、「マイ アカウント」からアクセスできます。op「フォーム」が呼び出されると、必要なすべてのアドレスを収集します。しかし、それらをテーマにする方法が見つかりません。現在、テーブルに適切に配置されているのではなく、いくつかのフィールドがページにダンプされています。私は「user-profile.tpl.php」を認識していますが、それを変更する他のモジュールがある可能性があるため、それを変更することはできません。

ユーザー カテゴリで適切なテーマのテーブルを作成する方法を知っている人はいますか?

よろしくゲヴュルツヴィーゼル

4

2 に答える 2

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;
}
于 2012-10-25T11:10:34.143 に答える
0

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

于 2011-07-19T13:47:38.860 に答える