Skip to main content

Drupal 8 Tutorials : Custom Module



Custom Module development in Drupal 8 is very simple. It may looks very difficult for developer who has Drupal 7 experience or nothing at all.

This tutorial will show easy steps and helps you to create custom module within few minutes.

Note:

Content or example of this tutorial may change according to Drupal 8 version and its release.

This tutorial is divided into three small sections.

In first section of this tutorial we will see what directory structure we need to create for a custom module.

In second section we will see what type files we need to create.

And in last section we will see what code we need to write in those files and configure them in Drupal 8.

1 Directory Structure


All custom module in Drupal 8 reside under “module” directory of Drupal 8 project.

To create a custom module we will create a new directory named “document” under custom folder.

Following is directory structure.







2 Configuration files

Second thing that we need to create is YAML files which represent custom module configurations.

Followings are files that you need to create.

  • {module name}.info.yml   i.e  document.info.yml
  • {module name}.module   i.e  document.module

only document.info.yml file is enough for configuring of document module.

Following is directory structure after including these files







3 Writing Configuration Settings

Add following code inside document.info.yml










Above configuration settings are very descriptive except only one parameter which is type.

As we are creating custom module therefore type parameter must be typed as module.

Now your module is ready to enable and use.

Go to Drupal Admin page and enable document module from

Admin->Extend link

Now search document module in search list

Then select check box before document module name and click “Save Configuration” button.

That’s it, custom document is now ready to use

Next tutorial will help you create custom controller for this custom module.

Comments

Popular posts from this blog

AngularJs Tutorial: Getting Started

This tutorial will help you to create a dynamic web application using power of AngularJs. ·   What is AngularJs AngularJs is javascript MVC framework (maintained by Google) which molds static HTML application to dynamic web application. That was a brief introduction, you can find more information on Wiki and AngularJS Site . AngularJs follows MVC pattern to separate out model from view and manage it by controller. See this image Goal of using AngularJs is to convert static HTML template to dynamic (Angular) template.   ·   How to convert static template to dynamic (Angular) Template Now consider the following static HTML template which contain list of movies title. <html> <head></head> <body>   <h1>Upcoming Movies</h1> <ul>     <li>       <span>Godzilla</span>     </li> <li>       <span>Batman vs Superman</span>     </li> <li>       <span>Sta

Abstract Factory design pattern analysis

What is Abstract Factory design pattern?     The intent or definition of Abstract Factory is “ Provide an interface for creating families of related or dependent objects without specifying their concrete classes ” It is kind of an obscure definition, in order to understand it we need to break it into meaningful pieces. 1.  " Provide an interface "  When we talk about Abstract Factory we talk about interface not abstract class , Basically this design pattern gives us an Interface, like Interface in Java, C# , Typescript (abstract class).    Why interface?  Whenever we talk about any design pattern, it emphasizes more on how we are going to use it rather than implement it. Interface is always the right type to prefer because concrete class creates tight coupling whereas an interface isolates it from the rest of the system. At runtime we can get different solution, without updating our code. For example interface SecurityFactory

AngularJs Tutorials : Bootstrap

Every application starts with bootstrap process which initialize application and wire it other with dependencies and configurations. AngularJs is not different from other application. It also starts application with bootstrap process. Following operation happens inside AngularJs bootstrap process. Load application module. Create dependency injector and load dependencies. Compile HTML and create scope for application. All these steps happens inside angular.js scripting file. therefore we need to include it first. we can include it inside HEAD tag or at end of BODY tag. Note: Adding angular.js file at end of body tag will allow browser to load of HTML elements without any delay and afterwards load angular.js and begin bootstrapping process. You can get angular.js source file from https://code.angularjs.org/ <script src= ”https://code.angularjs.org/1.3.0/angular.js” type= ”text/javascript” > AngularJs bootstrap process happens on docum