drupal模块开发

drupal模块的命名和目录结构 Naming and placing your Drupal 8 module

日期:2016-06-20 阅读:1962

dmandwp系统 - wordpress系统和DM系统区块建站>>

Naming and placing your Drupal 8 module  https://www.drupal.org/node/2116781 

There are some important rules to follow when selecting a machine name:

模块的命名,也就是机器名。这个很重要。规则如下:

It must start with a letter. 以字母开头
It must contain only lower-case letters and underscores. 只能是小写和下划线组成
It must be unique. Your module may not have the same short name as any other module, theme, or installation profile you will be using on the site.{不能重复}

It may not be any of the reserved terms : src, lib, vendor, assets, css, files, images, js, misc, templates, includes, fixtures, Drupal.(不能和保留字冲突)


For this case, we'll choose "hello_world" as the machine name. 这里,我们以 hello_world为例。

Important note: Be sure to not use upper-case letters in your module's machine name as Drupal will not recognize your hook implementations(模块名不能大写)

-------------

模块放在哪呢?

Given that our choice of machine name is "hello_world", start the module by creating a folder within your Drupal installation at the path: /modules/custom/hello_world or /sites/all/modules/custom/hello_world. Note that it is not necessary to use the same name for your module's folder as your machine name. You could, for example, use the folder name HelloWorld instead. However, you must remember to use the machine name programmatically within your module's code and filenames.

可以放在/modules/custom/hello_world 或 /sites/all/modules/custom/hello_world

另外,目录的名字,也可以是helloworld(注意,没有下划线,也就是说目录可以和模块名不一样。),但是,在模块的文件和代码里,必须和模块名一样,也就是机器名。

 

 

<<点击返回