2013-03-01 85 views
0

我是新来的Drupal,目前正在学习的Drupal 7Drupal 7的新创建自定义的模块不显示模块列表了

我对Drupal 7的指书

我试图创建我的第一个自定义模块

在这本书是一提的是,你可以在下面的目录

1)的一个创建模块/网站/所有/模块

2)/网站/默认/模块

我模块的

第一

我已经创建了我的模块/网站/默认/模块/第一

在这个目录有两个文件

1)first.info

2)first.module

内容的第一.info文件的fisrt.module文件

;$Id$ 
name = First 
description = A first module. 
package = Drupal 7 Development 
core = 7.x 
files[] = first.module 
;dependencies[] = autoload 
;php = 5.4 

内容是

<?php 
// $Id$ 
/** 
* @file 
* A module exemplifying Drupal coding practices and APIs. 
* 
* This module provides a block that lists all of the 
* installed modules. It illustrates coding standards, 
* practices, and API use for Drupal 7. 
*/ 
/** 
* Implements hook_help(). 
*/ 

function first_help($path, $arg) { 
if ($path == 'admin/help#first') { 
return t('A demonstration module.'); 
} 
} 
?> 

当我尝试检查模块的名单我不能够看到我创建模块

我已经厌倦了清理缓存和检查仍然没有显示

有谁能够告诉我,我在哪里错了。

在此先感谢

回答

3

模块位置
大多数人选择把模块在/sites/all/modules/sites/domain.com/modules文件夹(不sites/default...)。对于大多数常见的Drupal安装,你应该把它放在sites/all/modules

信息文件
只有您的信息文件中的名称,描述和核心是必需的。首先删除除这些值之外的所有内容。

name = First 
description = A first module. 
core = 7.x 

请参阅Writing module .info files (Drupal 7.x)了解更多信息。

一些注意事项:

  • “一揽子”财产
  • 你并不需要声明你的模块的.module文件中的“文件”属性“只应由大型的多模块封装中使用” 。
  • 现在删除注释掉的行。如果您的模块确实需要PHP 5.4,那么在完成故障排除后,您可以稍后将其添加回来。
+0

感谢您的回复,我尝试了你解释仍然不工作 – utsav 2013-03-01 12:03:40

+0

检查信息和模块文件上的文件名。您在上面都有错别字(信息文件名有空格,模块文件名拼写错误)。 – 2013-03-01 12:08:44

0
function test_example_help($path, $arg){ 
switch ($path) { 
case "admin/help#test_example": 
return '<p>' . t("test module to see how it works and shows") . '</p>'; 
break; 
} 

尝试使用switch语句来看看它是否工作

0

尝试取出?>标志着该​​PHP代码。此结束做是为了防止空白下面的例子分解HTTP标头。

1

我解决了这个问题,通过启动我的.info文件与

name = First 

,使我的文件编码:

UTF-8无BOM

你可以找到它容易当使用Notpade ++