随心芸芸 @ JPeanut(旧版)

搬迁至 http://www.17m.net.cn/

BlogJava 首页 新随笔 联系 聚合 管理
  43 Posts :: 0 Stories :: 54 Comments :: 0 Trackbacks
 [翻译:陈市明 摘自: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.这份指南将教会我们如何在一个drupal的结点上创建block content,创建链接和回复信息。
   首先在drupal的安装路径下创建目录sites/all/modules/onthisdate(呵呵 当然先得创建目录sites/all/modules哈)。在目录sites/all/modules/ onthisdate下创建一个文件,命名为onthisdate.module。在drupal 5.x中,目录sites/all/modules放置的是一些非核心模块。这个使得你在升级核心模块的时候更加方便,无需担心你之前定制化。
<?php
/* $Id$ */

   在每个模块的php文件末尾可以省去?>的标记,只要在开头加上<?php即可。$Id$则是有助CVS的版本控制。在你模块中,所有需要被Drupal调用的函数都必须以“{模块名}_{钩子名}”命名,钩子名是drupal中一些预定义的方法的前缀。通过这样的命名方式,可以很容易的让Druapl调用到这些方法,从而得到你定制的数据。
   这个模块目前还没运行起来,因为它还没有被激活。在后面的章节中,我们可以看到如何激活该模块。



原文
01. Getting started
Drupal 
5.x

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. 

posted on 2007-03-26 23:43 陈市明 阅读(341) 评论(0)  编辑  收藏 所属分类: 小陈的Drupal专区小陈翻译

只有注册用户登录后才能发表评论。


网站导航: