Category: Custom Module

The 10 most critical Drupal security risks


1. SQL Injection You shouldn't use data that you don't trust (as a feed, a user input, another database, etc) directly in a database query without escaping it: index.php?id=12 mysql_query("UPDATE mytable SET value = '". $value ."' WHERE id = ". $_GET['id']); Instead, you should use Drupal functions passing the user input as parameters: db_query("UPDATE {mytable} … Continue reading The 10 most critical Drupal security risks

How to Uninstall/Disable Module manually through the database in Drupal 8?


Working with Module is one of the Drupal’s strength. Drupal 8 Modules are easy to install and uninstall from Dashboard, but sometimes due to Fatal errors, Admin Access is not accessible. What to do when Admin can not access the site. Drush is the best option in this situation but what if Drush is not … Continue reading How to Uninstall/Disable Module manually through the database in Drupal 8?

How To Create Custom like module in Drupal 7

How To Create Custom like module in Drupal 7


Let’s start by creating the new Drupal module. To do that we should first create a folder called likepost in the sites\all\modules\custom directory of your Drupal installation as shown below: Inside this folder, you should create a file called likepost.info with the following contents: name = likepost description = This module allows the user to … Continue reading How To Create Custom like module in Drupal 7

How To Create an Example CRUD Module in Drupal 7


There are two basic files require to create a module i.e .info file (contains basic information of module like title, description, configuration link path, module version, Drupal version e.t.c) and .module file (contains functions which implement Drupal hooks to display menu and table e.t.c on admin panel or front site). Here I also used .install … Continue reading How To Create an Example CRUD Module in Drupal 7

Drupal 8 Theme folder structure


A theme is a collection of files that define the presentation layer. You can also create one or more "sub-themes" or variations on a theme. Only the .info.yml file is required, but most themes and sub-themes will use other files as well. This page lists the files and folders that are found in a typical … Continue reading Drupal 8 Theme folder structure

Create a custom form in Drupal 8

Create a custom form in Drupal 8


In Drupal 8 form API is similar to Drupal 7 Form API. forms still uses array structure to render the data. but having separate validation and submission form.Drupal 8 has some new (HTML 5) elements available. New HTML 5 elements like 'tel','email','number','date','url','search','range' etc. In Drupal 8 Form classes implement the \Drupal\Core\Form\FormBuilderInterface and the basic workflow … Continue reading Create a custom form in Drupal 8

7 ways to add custom JS and CSS to a page in Drupal


1. drupal_add_css(), drupal_add_js() This is the most common method used by most developers. Advantages Easy to use, can be inserted wherever you want; Can inset inline css/js; Easy to find documentation; Added files are cached; Supports conditions (browser, media etc.). Disadvantages Can be found anywhere in the code where you’re not expecting it; Including multiple … Continue reading 7 ways to add custom JS and CSS to a page in Drupal

Drupal interview questions for experienced Drupal Developer


1. what is entity  and entity api? Ans: They provide a unified way to work with different data units in Drupal. Drupal 7 is all about entities. They are everywhere: nodes, users, taxonomy terms, vocabularies… But how, as developers, can we create our own entities? When do we really need to do that? I think these … Continue reading Drupal interview questions for experienced Drupal Developer

Building a Drupal 7 Module: Show Latest Nodes

Building a Drupal 7 Module: Show Latest Nodes


The file shownodes.info provides the general information about your module to Drupal and the fileshownodes.module will contain the implementation for various hooks used by our module. The following is how the file structure should look for our module. Now open the shownodes.info file and add the following content: name = shownodes description = This module displays various nodes in a … Continue reading Building a Drupal 7 Module: Show Latest Nodes

Creating a custom module to write/save a Drupal node based on a submitted external form

Creating a custom module to write/save a Drupal node based on a submitted external form


The external formThis can be any old form, but for the purposes of this exercise, let's imagine that our form is something like this:<form action="http://example.com/your_endpoint/your_resource" method="post" enctype="multipart/form-data"> <table width="50%"> <tr> <td>Your name:</td><td><input name="name" type="text" /></td> </tr> <tr> <td>Job title:</td><td><input name="job_title" type="text" /></td> </tr> <tr> <td>Age:</td><td><input name="age" type="text" /></td> </tr> <tr> <td>Hometown:</td><td><input name="hometown" type="text" /></td> </tr> … Continue reading Creating a custom module to write/save a Drupal node based on a submitted external form