09. บอกให้ Drupal รู้ถึงการทำงานใหม่ (Letting Drupal know about the new function)
Submitted by wd on Wed, 2008-01-16 12:18
ถ้าฟังก์ชั่นไหนของเราไม่ใช่ฮุก เราต้องบอกให้ 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
- Log in or register to post comments
- 4396 reads







Recent comments