Skip to main content
Drupal 8

Main navigation

  • Home
    • Question And Answer
    • NEWS
    • Projects
  • Tutorials - Drupal
    • Android
    • Other
User account menu
  • Log in

Breadcrumb

  1. Home

Tutorials - Drupal

By editor , 2 February, 2024

Unit test with Drupal using PHPUnit (Drupal 10)

Tags

  • Drupal 8
  • Testing
  • Drupal 9
  • Drupal 10

Drupal testing framework (PHPUnit) provide 3 types of tests: UnitTest, KernelTest, FunctionalTest (JSFunctionalTest)
UnitTest : Very fast but Unit Only, without drupal.
KernelTest : Is a service test with drupal but without interfaces ans theming.

By nuwantha , 1 June, 2022

Drupal Security Best Practices

Tags

  • Drupal 8
  • Drupal 9
  • Security

1. Update drupal core and contrib odules to the last version
Example with composer if you use core-recommended:
composer update  drupal/core-recommended:9.3.14 -W

By editor , 8 March, 2022

Order and sort items with tabledrag

Tags

  • Drupal 8
  • Code
  • Drupal 9
  • Table

Draggable table Form Example


Step 1 : Form build

By editor , 12 January, 2022

Add a custom service YAML container

Tags

  • Drupal 8
  • Code
  • Settings
  • Services
  • YAML

Example: settings for local environnement.
Create the local settings file : local.services.yml the add to local settings.php file

# Local service config
$settings['container_yamls'][] = DRUPAL_ROOT . '/sites/default/local.services.yml';

By editor , 23 November, 2021

Apply a patch with composer

Tags

  • Drupal 8
  • Code
  • Composer

Step 1 : Add the package cweagans/composer-patches
composer require cweagans/composer-patches

By editor , 4 November, 2021

Conditional Form Fields (States)

Tags

  • Drupal 8
  • Code
  • Drupal 9

Doc : https://www.drupal.org/docs/drupal-apis/form-api/conditional-form-fields

States that can be applied to a form field element:

By editor , 3 November, 2021

Add Zip package to drupal using composer (Example : CKEditor colorbutton as drupal-library)

Tags

  • Drupal 8
  • Drupal 9
  • Composer

Add following packages to composer.json file next to drupal repository

By editor , 30 September, 2021

Translation API - PHP Twig JavaScript

Tags

  • Drupal 8
  • Drupal 9
  • Translation
  • JavaScript
  • Twig
  • PHP

PHP Class using StringTranslationTrait

StringTranslationTrait allow to get t() and formatPlural() methods
Example:
use Drupal\Core\StringTranslation\StringTranslationTrait;
use Drupal\Core\StringTranslation\TranslationInterface;
class MyClass {

By editor , 24 June, 2021

State API

Tags

  • Drupal 8
  • Code
  • Drupal 9

State servic eallow to store variables such as state of the server temporarily or permanently

By editor , 15 June, 2021

Drupal Site Settings : Using settings.php

Tags

  • Drupal 8
  • Code
  • Settings

Drupal settings file can contains variable which can use to use for different configuration in different environments.

Example:
env_name
default_info_nid

$settings['env_name'] = 'Local';
$settings['default_info_nid'] = 1';

Pagination

  • Page 1
  • Page 2
  • Page 3
  • Page 4
  • Page 5
  • Page 6
  • Page 7
  • Page 8
  • Page 9
  • …
  • Next page
  • Last page

Links

  • Drupal.org
  • Drupal core release cycle
  • Drupal events with ease
  • Unit test with Drupal using PHPUnit (Drupal 10)
  • Tokens for file upload url
  • Tips for Docker
  • CKEditor inline image files usage for custom forms.
  • Install Docker on Linux Mint
  • Install PHP 8.1
  • Drupal Security Best Practices
  • Order and sort items with tabledrag
  • Add a custom service YAML container
  • Apply a patch with composer