09. บอกให้ Drupal รู้ถึงการทำงานใหม่ (Letting Drupal know about the new function)
ถ้าฟังก์ชั่นไหนของเราไม่ใช่ฮุก เราต้องบอกให้ Drupal รับรู้ถึงฟังก์ชั่นเราเสมอ
ทำได้ผ่านฮุก onthisdate_menu() โดยกลับไปแก้ไขงานจากคราวก่อน
<?php
function onthisdate_menu() {$items = array();
//this was created earlier in tutorial 7.
$items['admin/settings/onthisdate'] = array(
'title' => 'On this date module settings',
'description' => 'Description of your On this date settings control',
'page callback' => 'drupal_get_form',
'page arguments' => array('onthisdate_admin'),
'access arguments' => array('access administration pages'),
'type' => MENU_NORMAL_ITEM,
);//this is added for this current tutorial.
$items['onthisdate'] = array(
'title' => 'On this date',
'page callback' => 'onthisdate_all',
'access arguments' => array('access onthisdate content'),
'type' => MENU_CALLBACK
);return $items;
}
?>
- เมื่อเรียกผ่าน URL ว่า
onthisdateฟังก์ชั่นonthisdate_all()จะทำงาน - ชนิด (
type) ของเมนู คือMENU_NORMAL_ITEMเป็นเมนูปกติที่ผู้ใช้มองเห็นMENU_CALLBACKไม่แสดงในเมนูจริง ๆ แต่จะถูกเรียกใช้ผ่านทาง URL เท่านั้น
ดูเพิ่ม
- Printer-friendly version
- Login or register to post comments
- 1694 reads







Recent comments
18 weeks 1 day ago
37 weeks 16 hours ago
47 weeks 2 days ago
1 year 9 weeks ago
1 year 13 weeks ago
1 year 13 weeks ago
1 year 13 weeks ago
1 year 13 weeks ago
1 year 14 weeks ago
1 year 14 weeks ago