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

Code

By editor , 3 January, 2017

Create a Drupal 9 Project using composer.

Tags

  • Drupal 8
  • Code
  • Composer

Using recommended-project template

 

composer create-project drupal/recommended-project my-project

For more information, see : https://www.drupal.org/docs/develop/using-composer/starting-a-site-using-drupal-composer-project-templates

 

By editor , 20 December, 2016

Drupal 8 Url Tips. Get Name, Path, Args ...

Tags

  • Drupal 8
  • Code

Drupal 8 Url Object
use Drupal\Core\Url;

Create a Url

Create Url from route name

$url = Url::fromRoute('<current>');
$url = Url::fromRoute('entity.node.canonical', ['node' => 1], []);

By editor , 8 December, 2016

Adding jQuery UI Widget to drupal 8

Tags

  • Drupal 8
  • Code
  • jQuery

Example :

Step 1 : Add libraries. Example: (With theme / or module : mytheme)

On : mytheme.libraries.yml file

By editor , 8 December, 2016

Create a configurable Block programmatically

Tags

  • Drupal 8
  • Code
By editor , 7 December, 2016

SimpleTest : Running PHPUnit tests from command line

Tags

  • Drupal 8
  • Code
  • Debug
  • Testing

Initialisation - Create link to the script (Optional).

ln -s core/scripts/run-tests.sh ~/bin

Run Test and open rest in web browser.

php core/scripts/run-tests.sh --browser --class "Drupal\YOUR_MODULE\Tests\JustTest"

By editor , 28 November, 2016

Add a Form in to a Basic Controller

Tags

  • Drupal 8
  • Code
  • Form
  • Drupal 9

NOTE: I don't know this is the best practice, anyway it's working !!!.

By editor , 22 November, 2016

Handle database schemas on Drupal 8

Tags

  • Drupal 8
  • Code
  • Database

Get Database Schema

$schema = \Drupal\Core\Database\Database::getConnection()->schema();

 

By editor , 12 November, 2016

Custom Content Entity Field types of drupal 8

Tags

  • Drupal 8
  • Code
  • Entity
  • Database
By editor , 30 October, 2016

Theme Negotiators - Switch theme dynamically

Tags

  • Drupal 8
  • Code
  • Theming

Create a custom module (here : example)

For active themes by route you first have to define a service in your $module.services.yml file:


On example.services.yml

Add:

By editor , 25 October, 2016

Drupal 8 Cache API

Tags

  • Drupal 8
  • Code
  • Cache

Get the default cache bin

$cache = \Drupal::cache();

To get a particular cache bin (here 'render'):

$render_cache = \Drupal::cache('render');

Pagination

  • Previous page
  • 8
  • Next page
Code

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