จะแปลงมอดูลจากตัวอย่าง คือ On This Date ซึ่งดู "วันนี้ในอาทิตย์ก่อน" มาเป็น Recent Week คือดูหัวข้อใหม่ในสัปดาห์นี้ (เหมือนกับ tracker แต่ทำเป็นบล๊อกได้)
เริ่มเลย $ cd /var/www/drupal/sites/all/modules
$ cp -xa onthisdate recentweek
$ cd recentweek
$ mv onthisdate.info recentweek.info
$ mv onthisdate.module recentweek.module
$ sed -i "s/onthisdate/recentweek/g" *
$ sed -i "s/on this date/recent week/g" *
$ sed -i "s/On this date/Recent week/g" *
$ sed -i "s/On This Date/Recent Week/g" *
$ vi recentweek.module
ได้ดังนี้ $ cd /var/www/drupal
$ mkdir -p sites/all/module/onthisdate
ไฟล์ info $ 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
ไฟล์ module $ vi onthisdate.module
<?php
/**
* Display help and module information
* @param path which path of the site we're displaying help
<?php
// add a more link to our page that displays all the links
$block_content .=
"<div class=\"more-link\">".
l(
t("more"),
"onthisdate",
array(
"title" => t("More events on this day.")
)
)."</div>";
?>
<?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',
<?php
function onthisdate_all() {
// content variable that will be returned for display
$page_content = '';
// Get today's date
$today = getdate();
// calculate midnight one week ago
$start_time = mktime(0, 0, 0, $today['mon'], ($today['mday'] - 7), $today['year']);
// we want items that occur only on the day in question,
Recent comments