04. ทำเรื่องบล๊อก (Declare we have block content)
Submitted by wd on Wed, 2008-01-16 12:15
ถ้ามอดูลเราทำบล๊อกด้วย เราต้องเขียนฟังก์ชั่นในรูป hook_block
ดังนี้
<?php
/**
* Generate HTML for the onthisdate block
* @param op the operation from the URL
* @param delta offset
* @returns block HTML
*/
function onthisdate_block($op='list', $delta=0) {
// listing of blocks, such as on the admin/block page
if ($op == "list") {
$block[0]["info"] = t('On This Date');
return $block;
}
} // end onthisdate_block
?>ตัวแปร $op เรียกว่า operation บอกว่าข้อมูลบล๊อกของเราอยู่ในรูปไหน ในที่นี้เป็น list
ตัวแปร $delta เรียกว่า offset บอกว่าระหว่างการแสดงผลเป็นบล๊อก หรือแสดงผลในรูปอื่นมีข้อแตกต่างกันหรือเปล่า
ดูเพิ่ม
- Printer-friendly version
- Log in or register to post comments
- 5541 reads







Recent comments