简体   繁体   English

drupal 7新创建的自定义模块未显示在模块列表中

[英]drupal 7 newly created custom module does not showing up in module list

i am new to drupal, currently learning drupal 7. 我是drupal的新手,目前正在学习drupal 7。

i am referring book for drupal 7 我指的是drupal 7的书

i was trying to create my first custom module 我正在尝试创建我的第一个自定义模块

in the book it was mention that you can create module in one of the following directory 在书中提到您可以在以下目录之一中创建模块

1) /sites/all/modules 1)/ sites / all / modules

2) /sites/default/modules 2)/ sites / default / modules

name of my module is first 我模块的名字是第一

i have created my module in /sites/default/modules/first 我已经在/ sites / default / modules / first中创建了我的模块

in this directories there are two file 在此目录中有两个文件

1) first.info 1) first.info

2) first.module 2) first.module

content of first .info files are 第一个.info文件的内容是

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

content of fisrt.module files are fisrt.module文件的内容是

<?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.');
}
}
?>

when i try to check list of modules i am not able to see module that i created 当我尝试检查模块列表时,我看不到我创建的模块

i have tired clearing cache and check still not showing 我已经清除了缓存,并且仍然无法显示

can anybody tell me where i am wrong. 谁能告诉我我错了。

Thanks in advance 提前致谢

Module Location 模块位置
Most people choose to put modules in the /sites/all/modules or /sites/domain.com/modules folders (not sites/default... ). 大多数人选择将模块放在/sites/all/modules/sites/domain.com/modules文件夹中(而不是sites/default... )。 For most common Drupal installations you should place it in sites/all/modules . 对于大多数常见的Drupal安装,应将其放置在sites/all/modules

Info File 信息文件
Only Name, Description and Core are required in your info file. 您的信息文件中仅需要名称,描述和核心。 Start by removing everything except those values. 首先删除除那些值之外的所有内容。

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

See Writing module .info files (Drupal 7.x) for more information. 有关更多信息,请参见编写模块.info文件(Drupal 7.x)

Some notes: 一些注意事项:

  • The "package" Property "should only be used by large multi-module packages" “包”属性“仅应由大型多模块包使用”
  • You don't need to declare your module's .module file in the "files" Property. 您无需在“文件”属性中声明模块的.module文件。
  • Remove the commented out lines for now. 现在删除注释掉的行。 If your module really requires PHP 5.4, you can add that back in later after you're done troubleshooting. 如果您的模块确实需要PHP 5.4,则可以在完成故障排除后将其重新添加。

I solved this problems by starting my .info file with 我通过使用以下命令启动.info文件来解决此问题:

name = First

and make my file encode: 并让我的文件编码:

UTF-8 without BOM 不带BOM的UTF-8

you can find it easy when using Notpade++ 使用Notpade ++时很容易

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;
}

try the following example using a switch statement to see whether it works 尝试使用switch语句查看以下示例,看看它是否有效

尝试去掉标记PHP代码结尾的?> ,这样做是为了防止空格破坏HTTP标头。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM