; $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."
In Drupal 5.x the basic information about your module, its name and description, is no longer provided by hook_help. Instead, all modules now need to have a modulename.info file, containing meta information about the module (for details see Writing .info files (Drupal 5.x)). For our example, "onthisdate.info'. The general format is:
; $Id$ name = Module Name description ="A description of what your module does."
Without this file, your module will not show up in the module listing!.
for our example, it could contain the following:
; $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."
Add the source above to a file named to onthisdate.info before saving in your module's directory at sites/all/modules/onthisdate. There are also three optional lines that may appear in the .info file: dependencies = module1 module2 module3 package="Your arbitrary grouping string" version ="$Name$"
For our example module, these don't apply and we will simply omit them. If you assign dependencies for your module, Drupal will not allow it to be activated until the required dependencies are met. If you assign a package string for your module, on the admin/build/modules page it will be listed with other modules with the same category. If you do not assign one, it will simply be listed as 'Uncategorized'. Not assigning a packagefor your module is perfectly ok; in general packages are best used for modules that are distributed together or are meant to be used together. If you have any doubt, leave this field blank.
Suggested examples of appropriate items for the package field:
* Audio * Bot * CCK * Chat * E-Commerce * Event * Feed Parser * Organic groups * Station * Video * Views * Voting (if it uses/requires VotingAPI)
The version line will provide the version string for users getting their modules directly from CVS rather than using the tarball package that is created with a release.
The files use the ini format and can include a ; $Id$ to have CVS insert the file ID information.
For more information on ini file formatting, see the PHP.net parse_ini_file documentation.
We can also provide help and additional information about our module. Because of the use of the .info file described above, this hook is now optional. However, it is a good idea to implement it. The hook name forthis function is 'help', so start with the onthisdate_help function:
<?php function onthisdate_help($section='') {
} ?>
The $section variable provides context for the help: where in Drupal or the module are we looking for help. The recommended way to process this variable is with a switch statement. You'll see this code pattern in other modules. <?php /** * Display help and module information * @param section which section of the site we're displaying help * @return help text for section */ function onthisdate_help($section='') {
$output ='';
switch ($section) { case"admin/help#onthisdate": $output ='<p>'. t("Displays links to nodes created on this date"). '</p>'; break; }
return $output; } // function onthisdate_help ?>
The admin/help#modulename case is used by the Drupal core to linked from the main help page (/admin/help or ?q=admin/help). You will eventually want to add more text to provide a better help message to the user.
More information about the help hook: Drupal HEAD
Add the source above to a file named to onthisdate.module before saving in your Drupal installation.
]]>Drupal5.x创徏自定义模块指南-01开?Creating modules - a tutorial: Drupal 5.x Q-01. Getting started)http://www.aygfsteel.com/JPeanut/archive/2007/03/26/106555.html陈市?/dc:creator>陈市?/author>Mon, 26 Mar 2007 15:43:00 GMThttp://www.aygfsteel.com/JPeanut/archive/2007/03/26/106555.htmlhttp://www.aygfsteel.com/JPeanut/comments/106555.htmlhttp://www.aygfsteel.com/JPeanut/archive/2007/03/26/106555.html#Feedback0http://www.aygfsteel.com/JPeanut/comments/commentRss/106555.htmlhttp://www.aygfsteel.com/JPeanut/services/trackbacks/106555.html[译:陈市?摘自:http://drupal.org/node/82926] To focus this tutorial, we'll start by creating a block module that lists links to content such as blog entries or forum discussions that were created one week ago.q䆾指南教会我们如何在一个drupal的结点上创徏block content,创徏链接和回复信息?br /> 首先在drupal的安装\径下创徏目录sites/all/modules/onthisdateQ呵?当然先得创徏目录sites/all/modules哈)。在目录sites/all/modules/ onthisdate下创Z个文Ӟ命名为onthisdate.module。在drupal 5.x中,目录sites/all/modules攄的是一些非核心模块。这个得你在升U核心模块的时候更加方便,无需担心你之前定制化?br />
To focus this tutorial, we'll start by creating a block module that lists links to content such as blog entries or forum discussions that were created one week ago. The full tutorial will teach us how to create block content, write links, and retrieve information from Drupal nodes. Start your module by creating a folder in your Drupal installation at the path: sites/all/modules/onthisdate You may need to create the sites/all/modules directory first. Create a PHP file and save it as onthisdate.module in the directory sites/all/modules/onthisdate. As of Drupal 5.x, sites/all/modules is the preferred place for non-core modules (and sites/all/themes for non-core themes), since this places all site-specific files in the sites directory. This allows you to more easily update the core files and modules without erasing your customizations.
<?php /* $Id$ */
As per the Coding standards, omit the closing ?> tag and use the longhand <?php tag. The $Id$ string will help keep track of the revision number and date when you commit the file to CVS.
All functions in your module that will be used by Drupal are named {modulename}_{hook}, where "hook" is a pre-defined function name suffix. Drupal will call these functions to get specific data, so having these well-defined names means Drupal knows where to look. We will come to hooks in a while.
The module is not operational yet: it hasn't been activated. We'll activate the module later in the tutorial.
]]>Drupal Object Reference--$node - Node object(Drupal l点对象) for drupal 5.1http://www.aygfsteel.com/JPeanut/archive/2007/03/25/106281.html陈市?/dc:creator>陈市?/author>Sun, 25 Mar 2007 14:34:00 GMThttp://www.aygfsteel.com/JPeanut/archive/2007/03/25/106281.htmlhttp://www.aygfsteel.com/JPeanut/comments/106281.htmlhttp://www.aygfsteel.com/JPeanut/archive/2007/03/25/106281.html#Feedback0http://www.aygfsteel.com/JPeanut/comments/commentRss/106281.htmlhttp://www.aygfsteel.com/JPeanut/services/trackbacks/106281.html
[译:陈市?摘自:http://drupal.org/node/49768]
Node对象: [name] => 创徏l点的用户名 [date]
=> 创徏l点的时?br />[status]
=> 是否发布{True:发布|False:未发?/font>
}(在action+workflow中可以做审核处理)
[moderate]
=> 是否可修改{0:只读|1:修改} [promote]
=> 是否发布首页{0:是|1:否}
[sticky]
=> 是否|顶{0:否|1:是} [revision]
=>
TRUE/FALSE this is a new revision (if TRUE, will be saved as a separate entry in the database) [comment]=> 对该l点是否允许d,阅读或者是对其讄权限 [simple_access]=> Ҏ(gu)限模块的一?br />[title] => 昄l点面的标?br />[taxonomy] => 分类(数组,具体查看Taxonomy模块) [body] => l点的内?br />[format] => W合Filter模块的Content内容 [uid] => 创徏l点的用户ID [created] => 创徏l点的Unixcd的时间戳 [type] => l点cd(?book,page,forum,具体查看cck模块) [teaser] => 内容概要 [validated] => 该结Ҏ(gu)否有效{0:否|1:是}(是否已经保存) [changed] => 修改l点的Unixcd的时间戳 [nid] => l点ID
原文:
&$node - Node object
[name] => Username of node creator [date] => Date the node was created [status] => TRUE/FALSE = published/unpublished [moderate] => Moderation enabled (0|1) [promote] => Promoted to front page (0|1) [sticky] => Sticky (0|1) [revision] => TRUE/FALSE this is a new revision (if TRUE, will be saved as a separate entry in the database) [comment] => whether comments can be added, read, or accessed, forthis node [simple_access] => Array -- A list of permissions for the Simple Access module ( [view] =>0 )
[format] => which filter applies to this content. [uid] => User ID of node creator [created] => UNIX timestamp of node creation date. [type] => Type of node (e.g. book, page, forum) [teaser] => Teaser (the initial part of the body)
[validated] => has the node passed validation? (0|1) (is it ready to be saved). [changed] => UNIX timestamp of last time node was changed. [nid] => Node ID