อยากจะเพิ่ม user id เข้าไปเป็น column ในหน้า admin/user/user ทำอย่างไรได้บ้างครับ

By toncrub

ผมเข้าไปเพิ่มฟังก์ชั่นใน template.php ตามหน้านี้ครับ http://api.drupal.org/api/function/theme_user_admin_account/6

$header = array(
theme('table_select_header_cell'),
......  // <- โค้ดเดิม
array('data' => t('ID'), 'field' => 'u.id'),   //<- โค้ดที่เพิ่ม
.......  // <- โค้ดเดิม
);

กับส่วนนี้

foreach (element_children($form['name']) as $key) {
      $rows[] = array(
        drupal_render($form['accounts'][$key]),
        drupal_render($form['name'][$key]),

อันนี้ไม่รู้ว่าต้อง foreach เอา form ไหนมาครับ ถึงจะได้ user id ออกมาครับ

ลองอ่าน hook ดูแล้วก็ยังไม่เข้าใจครับ เลยต้องมารบกวนขอคำแนะนำครับ ขอบคุณมากครับ

2 comments

รูปภาพของ ball.in.th
By ball.in.th
1 ปี 34 weeks ago

อันนี้เกี่ยวกับการธีม form

อันนี้เกี่ยวกับการธีม form จะยุ่งพอสมควรครับ น่าจะต้องแก้ form ใน user_admin_account() ด้วยครับ
แต่กรณีนี้ง่าย เพราะ uid มีข้อมูลอยู่แล้ว

  $header = array(
    theme('table_select_header_cell'),
    array('data' => t('Username'), 'field' => 'u.name'),
    array('data' => t('ID'), 'field' => 'u.uid'), // ต้องเป็น uid
    array('data' => t('Status'), 'field' => 'u.status'),
    t('Roles'),
    array('data' => t('Member for'), 'field' => 'u.created', 'sort' => 'desc'),
    array('data' => t('Last access'), 'field' => 'u.access'),
    t('Operations')
  );
...
...
      $rows[] = array(
        drupal_render($form['accounts'][$key]),
        drupal_render($form['name'][$key]),
        $key, // $key เป็น uid
        drupal_render($form['status'][$key]),
        drupal_render($form['roles'][$key]),
        drupal_render($form['member_for'][$key]),
        drupal_render($form['last_access'][$key]),
        drupal_render($form['operations'][$key]),
      );

By toncrub
1 ปี 34 weeks ago

ใส่แค่ $key อย่างเดียวจริงๆ

ใส่แค่ $key อย่างเดียวจริงๆ ด้วย ขอบคุณมากครับ :)