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 , 30 September, 2016

Edit and Update Entity schema on drupal 8

Tags

  • Drupal 8
  • Code
  • Entity

Add a new field:

Example 1 Automatic update:

1. Update baseFieldDefinitions() of the Entity.
2. Apply update from a mymodule_update_N(). Ex:

By editor , 30 September, 2016

Alter a view. Edit view result programmatically

Tags

  • Drupal 8
  • Code
  • Views
  • Drupal 9

Example : Change title

By editor , 30 September, 2016

Create HTML Table. render and theming

Tags

  • Drupal 8
  • Code
  • Theming

Example : Table.

$header = ['#','Name', 'Mail'];
$data = [
  [1,'Name 1', 'Mail1@example.com'],
  [2,'Name N°2', 'second@example.com'],
];

By editor , 30 September, 2016

HTML List render and theming

Tags

  • Drupal 8
  • Code
  • Theming

Example : List

By editor , 29 September, 2016

Execute a drush command programmatically

Tags

  • Drupal 8
  • Code
  • Drush
  • Drupal 7

Methodes:

drush_invoke (For the current site)
drush_invoke($command, $arguments = array());

drush_invoke_process
This creates a new process in a new Drupal instance. There for you must specify the site alias.

By editor , 27 September, 2016

Get Theme details (Name, Regions, Libraries ...)

Tags

  • Drupal 8
  • Code
  • Theming

Get current theme.

$theme = \Drupal::theme()->getActiveTheme();

Theme name:

$theme_name = \Drupal::theme()->getActiveTheme()->getName();

By editor , 26 September, 2016

Drupal 8 breadcrumb functions (menu_get_active_trail, and menu_link_get_preferred ...)

Tags

  • Drupal 8
  • Code

Those functions [ menu_set_active_item(), menu_set_active_trail(), menu_get_active_trail(), menu_link_get_preferred() ] are removed on D8 and replaces with drupal 8 service. You can use following example to get data and to edit.

Example :

By editor , 16 September, 2016

Drupal 8's HTML elements render and themes

Tags

  • Drupal 8
  • Code
  • Theming

Use custom twig template or alter an existence.

Create a custom module then use hook_theme()

By editor , 1 September, 2016

Isset() VS Empty() VS Is_null()

Tags

  • PHP
  • Code
By editor , 29 August, 2016

Change Date format on Views BEF

Tags

  • Drupal 8
  • Code
  • Drupal 7
  • Views

There are several methodes.

Change date format Using custom module.

Pagination

  • Previous page
  • 10
  • 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