02. บอกว่ามอดูลเราจะทำอะไร (Telling Drupal about your module)
Submitted by wd on Wed, 2008-01-16 12:14
ต้องสร้างไฟล์ module_name.info สำหรับบอก Drupal ตัวอย่างนี้คือ
$ vi onthisdate.info
; $Id$
name = On this date
description = A block module that lists links to content such as blog entries or forum discussions that were created one week ago.
core = 6.x
ต้องมีหัวข้อดังนี้
- name
- บอกชื่อมอดูล
- description
- บอกคนอื่นให้รู้ว่ามอดูลทำอะไร สั้น ๆ 1 บรรทัด ถ้ามีอักขระแปลก ๆ ต้องเขียนด้วย HTML entities เพื่อให้แสดงผลในเว็บได้ เช่น
description = This is my "crazy@email.com" email address instead of description = This is my "crazy@email.com" email address
- core
- บอกให้รู้รุ่น Drupal เพราะเขาใช้เป็นตัวแยกว่าอันไหนจะเปิดให้ใช้งานบ้าง เวลาอัปเกรด
อาจมีหัวข้อดังนี้
- ดีเพนเดนซี (dependencies)
- บอกให้รู้ว่ามอดูลเราต้องการมอดูลไหนเป็นฐานบ้าง
dependencies[] = taxonomy dependencies[] = comment - แพกเกจ (package)
- บอกให้รู้ว่ามอดูลเรามีเพื่อนร่วมมอดูลอะไรบ้าง
package = "ชื่อมอดูลที่ร่วม"
ลองฟังก์ชั่นแรกคือ help
$ vi onthisdate.module
<?php
/**
* Display help and module information
* @param path which path of the site we're displaying help
* @param arg array that holds the current path as would be returned from arg() function
* @return help text for the path
*/
function onthisdate_help($path, $arg) {
$output = '';
switch ($path) {
case "admin/help#onthisdate":
$output = '<p>'. t("Displays links to nodes created on this date") .'</p>';
break;
}
return $output;
} // function onthisdate_help
?>
ตัวแปร $path แทนพาธว่า help ของเราจะไปอยู่ตรงไหน
ดูเพิ่มที่
- Printer-friendly version
- Login or register to post comments
- 2943 reads







Recent comments
18 weeks 1 day ago
37 weeks 17 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