Drupal学习笔记(一)

学习写一个Drupal模块。

编写一个.info模块信息文件,文件名要与模块的名字相同。

name = Annotate   //模块名
description = "Allows users to annotate nodes."  //关于这个模块的描述
package = Pro Drupal Development   //我的理解类似与于命名空间,也就是该模块属于哪一个类型
core = 7.x
files[] = annotate.module   //files数组是与这个模块相关联的文件
files[] = annotate.install
files[] = annotate.admin.inc
configure=admin/config/content/annotate/settings

编写.module文件

First, we’ll define a path where we can access our settings. Then, we’ll create the settings form. To make a path, I need to implement a hook,specifically hook_menu.

首先要定义一个我们能够设置的路径,然后创建一个设置表单页面。

hook_menu()  定义管理员菜单项

function annotate_menu() {
$items['admin/config/annotate'] = array(
'title' => 'Node annotation',
'description' => 'Adjust node annotation options.',
'position' => 'right',
'weight' => -5,
'page callback' => 'system_admin_menu_block_page',
'access arguments' => array('administer site configuration'),
'file' => 'system.admin.inc',
'file path' => drupal_get_path('module', 'system'),
);
$items['admin/config/annotate/settings'] = array(
'title' => 'Annotation settings', //链接名称
'description' => 'Change how annotations behave.',  //描述
'page callback' => 'drupal_get_form',  //应该是生成表单的函数
'page arguments' => array('annotate_admin_settings'), //表单ID
'access arguments' => array('administer site configuration'),  //后台页面配置权限   就是能访问配置页面
'type' => MENU_NORMAL_ITEM,
'file' => 'annotate.admin.inc',
);
return $items;
}




  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值