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

Drupal 8

By editor , 4 December, 2020

Use IMCE files browser for custom field on Drupal 8/9

Tags

  • Drupal 8
  • Code
  • Drupal 9
  • Images

You can use IMCE to select a file.

By editor , 26 November, 2020

Drupal 9 add inline JavaScript to a page programmatically

Tags

  • Drupal 8
  • Code
  • JavaScript

Method 1 : Form hook_page_attachments

By editor , 26 November, 2020

Private Tempstore - Store data on Drupal 9 session

Tags

  • Drupal 8
  • Code
  • Drupal 9
  • Cache

This method allow to store data on drupal session using drupal session table (not php $_SESSION).
Storage is different for each users ans each visitors if anonymous

By editor , 26 November, 2020

Redis and Php-Redis with drupal 9 on Linux

Tags

  • Drupal 8
  • Settings
  • Drupal 9
  • Cache

Install Redis

sudo apt-get update && sudo apt-get upgrade
sudo apt install redis-server
sudo apt install php-redis

Check

sudo systemctl status redis-server
redis-cli ping

By editor , 8 November, 2020

Disable cache for specific page

Tags

  • Drupal 8
  • Code
  • Drupal 9

Syntax:

\Drupal::service('page_cache_kill_switch')->trigger();

 

Example on a controller:

By editor , 9 July, 2020

Testing (SimpleTest) Install/Run Error

Tags

  • Drupal 8
  • Code
  • Testing

Error N°1 : PHPunit not found

If uou have a message like : Add Phpunit via composer

CAUTION : PHPunit Version >= 8 is not compatable with drupal, so use the 7

composer require --dev phpunit/phpunit:7

By editor , 11 October, 2019

Run PHP script using drupal bootstarp on drupal site

Tags

  • Drupal 8
  • Code
  • PHP

This is usefull if you want to do some actions just one time.

The drush comman is php-script alias src

On drupal 8 with drush

Example :
drush --uri=drupal.loc scr /modules/custom/mymodule/scripts/test-script.php

By editor , 1 November, 2018

Alter Views title programmatically on Drupal 8

Tags

  • Drupal 8
  • Code
  • Views
  • Hook

function MYMODULE_views_pre_render(ViewExecutable $view) {
 if ($view->id() == 'ABC') {
  $view->setTitle('MY CUSTOM TITLE');
 }
}

By editor , 21 June, 2018

Create Drush 9 Commands For Drupal 8

Tags

  • Drupal 8
  • Code
  • Drush

Drush 9 is finally here with some much-awaited changes. Drush 9 commands are now classes and .inc files are obsolete. Drush commands will now be based on the Annotated Command format. This will change the fundamental structure of custom Drush commands.

By editor , 23 May, 2018

Search Entities when using Domain Access

Tags

  • Drupal 8
  • Code
  • Entity

Example 1 : Without changing user session.

$query = \Drupal::entityQuery('node');
$query->condition(DOMAIN_ACCESS_FIELD, 'domain_id'); // Set the domain id hear
$query->condition('type', 'article');
$query->condition('status', 1);

Pagination

  • Previous page
  • 2
  • Next page
Drupal 8

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