[Drupal学习二]第一个模块编写

本文介绍如何在Drupal中创建自定义模块annotate,使用户能够在节点上添加注释。具体步骤包括建立模块文件夹、编写信息文件及核心模块文件。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

1. 在Drupal_Installation\sites\all\modules中新建一个文件夹annotate,注意这个名字其实就是我要创建的模块名称。在相应的地方要注意拼写是否一致。

2.在Drupal_Installation\sites\all\modules\annotate目录下创建一个信息文件 annotate.info,内容如下:

; $Id: annotate.info,v 1.6 2010/03/21 22:15:58 $
name = Annotate
description = Allows users to annotate nodes.
core = 3.x


; Information added by Tony He packaging script on 2010-03-21
version = "3.x-3.5"
core = "6.x"
project = "annotate"
datestamp = "1243161838"



3.同样在目录下创建文件annotate.module,暂时的内容(还未设定业务逻辑)如下:

<?php
// $Id$
/**
* @file
* Lets users add private annotations to nodes.
*
* Adds a text field when a node is displayed
* so that authenticated users may make notes.
*/
?>

注意:annotate.info中第二段信息中的core,因为我当前用的Drupal是drupal-6.16,当我将这个core改为不是6.x的是后, 刷新modules list的时候会报错:"This version is incompatible with the 6.16 version of Drupal core.". 可能是需要版本上的一致吧。
还有,为了创建module,至少需要2个文件即.info和.module文件,否则Drupal是不会认的。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值