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 , 18 December, 2015

Filter input text with Drupal Text Formats

Tags

  • Drupal 8
  • Code

Like Drupal 7, you can use check_markup();

CAUTION : This must only use on a rendered HTML page

By editor , 17 December, 2015

Move a file in drupal 8

Tags

  • Drupal 8
  • Code

file_move(FileInterface $source, $destination = NULL, $replace = FILE_EXISTS_RENAME)

Example:

$file = \Drupal\file\Entity\File::load($fid);
file_move(FileInterface $source, 'path/to/destination');

By editor , 17 December, 2015

Create a static progress bar on drupal 8

Tags

  • Drupal 8
  • Code
  • Theming

The easiest way is use html default progress bar like:

<progress value='$percentage' max='100'></progress>

And theme with CSS.

By editor , 16 December, 2015

Get a Image file path (src) on Drupal 8/9

Tags

  • Drupal 8
  • Code
  • Images
  • Drupal 9

Get the image file src (url)   
    $fid = 1;//The file ID   
    $file = \Drupal\file\Entity\File::load($fid);
    $path = $file->getFileUri();

By editor , 16 December, 2015

Handle file usage with drupal 8

Tags

  • Drupal 8
  • Code

Equivalent syntax Drupal 7 -> Drupal 8

By editor , 16 December, 2015

Event on Entity / Node / User ... delete

Tags

  • Drupal 8
  • Code
  • Node
  • User

For this, You must use hook_entity_delete.

Example :
function mymodule_entity_delete(\Drupal\Core\Entity\EntityInterface $entity) {
  $entity_type = $entity->getEntityTypeId();
  $entity_id = $entity->id();

By editor , 14 December, 2015

Get args from URL in Drupal 8

Tags

  • Drupal 8
  • Code

Example: 

By editor , 10 December, 2015

Set the page title programmatically in Drupal 9

Tags

  • Drupal 8
  • Code
  • Drupal 9

Change on a form or controller

Just set ['#title'] element.

Form Example : $form['#title'] = "The title";

By editor , 9 December, 2015

Login programmatically as a user

Tags

  • Drupal 8
  • Code
  • User

Example:
$user = User::load($uid);
user_login_finalize($user);

By editor , 9 December, 2015

Get all user's roles

Tags

  • Drupal 8
  • User
  • Code

Get All roles:
    $roles = \Drupal\user\Entity\Role::loadMultiple();

Pagination

  • First page
  • Previous page
  • …
  • Page 17
  • Page 18
  • Page 19
  • Page 20
  • Page 21
  • Page 22
  • Page 23
  • Page 24
  • Page 25
  • …
  • 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