Sign in Registration
ruen

Drupal modules, how to write your own module

Drupal is quite rich in its basic functionality. From version to version, new features were periodically included in the kernel and unnecessary ones were removed, as, incidentally, this happens in all software products. You can expand the functionality using modules.

drupal-modules

What is a module? This is a separately rendered code, which is formatted and structured in a certain way. In other systems, such units of code are called plugins, add-ons, extensions, etc., Drupal decided to call them modules. Module for Drupal is designed as a simple folder where the necessary files are located.

To expand the functionality of the system, you can use the standard modules that come with the Drupal core, you can also download any modules from the official website. But if you have reviewed all the modules and did not find the right one, then it is worth developing your own module for Drupal . This is an easy process if you have basic knowledge of Drupal and PHP.

Where are Drupal modules located ? The modules supplied with the kernel are located in the / modules folder at the root of the site. Modules that are downloaded and connected separately must be placed only in the / sites / all / modules / folder, or it can be / sites / site-name / modules / - in case of multisiting. After placing it in the folder, the module must be enabled in the Drupal settings, from this moment the module code will be used during the system operation. Drupal has its own internal scheme for connecting modules, which, with each page request, checks for the presence of modules and their activation, after which functions from the module are called, hooks are executed, etc.

To develop your own module for Drupal , it is enough to look at a sample from any existing module, it is best to take a module with a small size as an example, so it will be easier to understand the structure of Drupal modules. The minimum number of module files is 2 files, this is a file with the extension * .info , which contains a description and a file * .module - it contains the functionality of the module, which is written in accordance with with Drupal API .

A small example, let's say a module for Drupal 7 is called Module, then in the module folder you need to create a module.info file with the following content:

  name = Name
description = Description
package = Package
core = 7.x
version = "7.x-1.00"
 

Everything is intuitive here, the name, description, package, kernel version and module version are listed. The key is on the left, and the values ​​are on the right. Next, create a module.module file, in which you can write the required functionality, all functions must begin with the module_ prefix.

Thus, developing a Drupal module is an easy task that almost anyone can do. In more detail, the procedure for creating a module with an example will be discussed in the following articles.

Comments (0)
For commenting sign in or register.
Оставить заявку

Latest articles

Popular sections

Eqsash (Tools)

Android app - VK LAST USER ID, отучитель от зависимости и т.д.:
Available on Google Play

Amessage (Communication)

Login to the web version
Android app:
Available on Google Play

Share this

Subscribe to

YouTube

Books

IT notes - In simple language about the most necessary things (HTML, CSS, JavaScript, PHP, databases, Drupal, Bitrix, SEO, domains, security and more), PDF, 500 p.