Drupal at your Fingertips

Sub-title: 
Modern Drupal developer's quick code reference for version 10
Authors: 

Selwyn Polit
with contributions from the Drupal community

Publisher: 
self
Publication date: 
2024-01
Page count: 
100
ISBN-13: 
na

Drupal at Your Fingertips is a free living Modern Drupal reference book created to help developers quickly find code they need. It is a community effort including other developers' input. Please share it with your network.

Some of the chapters include:

  • Actions - Use the Drupal core actions module to control Drupal.
  • Batch and Queue - Digging into the Batch API and Queue subsystem to take on large tasks.
  • Blocks - Creating custom blocks, block types, block plugins, block forms, block visibility, block access, block regions, block templates, and block preprocess functions.
  • Caching - Understanding the cache system, cache tags, cache contexts, cache max-age, cache bins, cache backends, cache invalidation, cache rebuild, cache clear, cache warm, and cache performance.
  • Composer - Using Composer to manage dependencies and patches.
  • Configuration - Managing configuration files, configuration entities, configuration forms, configuration schema, configuration split, configuration import, configuration export, and configuration override.
  • Cron - Using hook_cron, sample crontab files, how to stop cron.
  • Debugging - Using debugging tools, debugging methods, debugging variables, debugging queries, debugging routes, debugging hooks, debugging events, debugging tests, and debugging performance.
  • Drush - Installing and using Drush, generating code, scaffolding modules, creating entities, updating database, debugging site, and running tests.
  • Forms - Creating and altering forms, form elements, form validation, form submission, form redirection, form states, form storage, form AJAX, form theming, and form API.
  • Hooks - Understanding the hook system, implementing hooks, altering hooks, invoking hooks, creating custom hooks, and debugging hooks.
  • Menus - Creating and altering menus, menu links, menu trees, menu blocks, menu templates, menu preprocess functions, and menu API.
  • Modules - Creating and altering modules, module structure, module dependencies, module installation, module uninstallation, module updates, module hooks, module events, and module testing.
  • Routes and controllers - Creating and altering routes, route parameters, route requirements, route options, route controllers, route access, route responses, and route API.
  • Services and Dependency injection - Understanding the service container, creating and altering services, service definitions, service arguments, service tags, service injection, service discovery, and service API.
  • Testing - Writing and running PHPUnit and Drupal Test Traits tests.
  • Twig - Using and extending Twig, Twig syntax, Twig filters, Twig functions, Twig variables, Twig templates, Twig debugging, Twig caching, and Twig API.
  • Update - Upgrading and patching Drupal and contrib modules.

Note. you can buy a pdf version from leanpub.

Drupal 8 module development, 2nd edition

Authors: 

Daniel Sipos
with Foreword by Dries Buytaert, founder of Drupal.

Publisher: 
Packt Publishing
Publication date: 
2019-03
Page count: 
580
ISBN-13: 
9781789612363

Drupal 8 comes with a release cycle that allows for new functionality to be added at a much faster pace. However, this also means code deprecations and changing architecture that you need to stay on top of. This book updates the first edition and includes the new functionality introduced in versions up to, and including 8.7.

The book will first introduce you to the Drupal 8 architecture and its subsystems before diving into creating your first module with basic functionality. You will work with the Drupal logging and mailing systems, learn how to output data using the theme layer and work with menus and links programmatically. Then, you will learn how to work with different kinds of data storages, create custom entities, field types and leverage the Database API for lower level database queries.

You will further see how to introduce JavaScript into your module, work with the various file systems and ensure the code you write works on multilingual sites. Finally, you will learn how to programmatically work with Views, write automated tests for your functionality and also write secure code in general.

By the end, you will have learned how to develop your own custom module that can provide complex business solutions. And who knows, maybe you’ll even contribute it back to the Drupal community.

Foreword by Dries Buytaert, founder of Drupal.

Drupal 8 Module Development

Sub-title: 
Build and customize Drupal 8 modules and extensions efficiently
Authors: 
Publisher: 
Packt Publishing
Publication date: 
2017-11
Page count: 
566
ISBN-13: 
9781782168775

Drupal is an open source web-based content management system (CMS) that can be used for building anything from simple websites to complex applications. It enables individuals and organizations to build platforms that engage users and deliver the right content at the right time.

Drupal 8 is an exciting new development in the Drupal community. However, the differences from the previous version are substantial and this can put quite some pressure on Drupal 7 developers that need to catch up. This book aims to help such developers in getting up to speed with Drupal 8 module development.

The book first introduces you to the Drupal 8 architecture and its subsystems before diving into creating your first module with basic functionality. Building upon that, you will cover many core APIs and functionalities available to module developers.

You will work with the Drupal logging and mailing systems, learn how to output data using the theme layer, and work with menus and links programmatically. Then, you will learn how to work with different kinds of data storages, create custom entities, field types, and leverage the Database API for lower level database queries. Moreover, you will learn about the Drupal 8 access system and caching layer as well as the APIs used for data processing (queues and batches).

You will further see how to introduce javascript into your module, work with the various file systems, and ensure the code you write works on multilingual sites. Finally, you will learn how to programmatically work with Views, write automated tests for your functionality, and also write secure code in general.

By the end of the book, you will have learned how to develop your own custom module from scratch that can help solve a small problem or even provide complex functionality. And who knows, maybe you’ll even contribute it back to the Drupal community.

How we create a node from custom form

How we create a node from custom form on Drupal 7

Step 1: Create a custom form .

function hook_menu() 
{
	$items ['create_custom_form_menu'] = array (
		   'page callback'		=>	'drupal_get_form',
		   'title'				=>	'Create Custom form', 
		   'page arguments'		=>	array ('create_custom_form'),
		   'access arguments'	=>	array ('create custom form' ),
		    'type'				=>	MENU_NORMAL_ITEM
		   );
       // After user login it will use for saving the form value that saved in sessions . Session variables are used a node variable on saving process 
	$items ['formloginredct'] = array (
		   'page callback'		=>	'formloginredct',
		   'access arguments'	=>	array ('create custom form' ),
		    'type'				=>	MENU_NORMAL_ITEM
		   );		   
	return $items;
}
// Assign a tpl for the form
function hook_theme($existing, $type, $theme, $path){
	return array(
			      'create_custom_form' => array(
      		              'arguments' => array('form' => NULL),
		              'template' => 'templates/forms/create_custom_form',
    	                      ),
	                   );
}

Define form contents..
<?php
function create_corporate_tour_form()
{
$form['#action'] = '#CustomForm';
// ...... define form contents
$form["buttons"] = array(
'#value'=>'Finish',
'#type'=>'submit',

Subscribe with RSS Subscribe to RSS - Custom development