我们的 sitenews.module 文件的开头还是老样子。先是一段儿文档,然后实作hook_help() 钩子,提供管理页面的帮助:
<?php // $Id$ /** * The sitenews module. * This module adds a content type (News Brief), and * provides an action (Send site news) that allows * administrators to send periodic updates (via email) * about the latest happenings. * * It also defines a new hook (hook_sitenews()) and * defines a new filter (News Brief Placeholders). * * @file */ /** * Implementation of hook_help(). */ function sitenews_help($path, $arg) { if ($path == 'admin/help#sitenews') { $txt = 'Keep users up-to-date by sending them a status ' .'report about the latest site happenings. To use this ' .'module, you will need to assign a trigger to the ' .'"Send site news as email to all users" action. It ' .'is recommended that the node publish event be tied to this' .'action, as that will result in the site news being sent' .'whenever a new "news brief" node is published.'; $replace = array(); return '<p>'. t($txt, $replace) .'</p>'; }
帮助文本有点儿长,除此之外上面这块代码中没什么令人吃惊的东西。
写得好的帮助很难找
在本书中,帮助文本都很简明。但是编写产品模块时,最好编写更好的帮助文本。看看核心代码就知道帮助文本应该是什么样子了。
下面我们继续介绍头两个函数,它们定义了新的内容类型。