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

Add a message to Drupal 8 Log system

Tags

  • Drupal 8
  • Code

Examples:

By editor , 4 December, 2015

Values of return array of a page

Tags

  • Drupal 8
  • Code
By editor , 3 December, 2015

Use arguments and parameters in url routes

Tags

  • Drupal 8
  • Code

Exemple 1 : Form with Node
in routing.yml
my.node.info:
  path: '/user/contactmail/{node}'
  defaults:
    _form: '\Drupal\myx_meet\Form\ContactUserForm'
    _title: 'Contact'
  requirements:

By editor , 2 December, 2015

Get field value of a Node / Entity

Tags

  • Drupal 8
  • Code
  • Node

Methode 1 : Example:

$value = $node->get($field)->value;
$target = $node->get($field)->target_id; // For entity ref

Methode 2 Example:

By editor , 2 December, 2015

Get node from url

Tags

  • Drupal 8
  • Code
  • Node

Example:

$node = \Drupal::routeMatch()->getParameter('node');
if ($node) {
  $nid = $node->id();
}

By editor , 2 December, 2015

Get the current user in drupal 8

Tags

  • Drupal 8
  • User
  • Code

Example:

    //use Drupal\user\Entity\User;
    $userCurrent = \Drupal::currentUser();
    $user = \Drupal\user\Entity\User::load($userCurrent->id());
    $name = $user->getUsername();

By editor , 2 December, 2015

Create taxonomy term programmatically on Drupal 8

Tags

  • Drupal 8
  • Taxonomy
  • Code

Example : Create a terom of the vocabulary 'test_vocabulary'

By editor , 1 December, 2015

Get all languas of the site in Drupal 8

Tags

  • Drupal 8
  • Code
  • Translation

To get languages in English:
$site_languages = \Drupal::languageManager()->getLanguages();

To get languages in native language:
$site_languages = \Drupal::languageManager()->getNativeLanguages();

By editor , 1 December, 2015

Download a file from URL

Tags

  • Drupal 8
  • Code

Example:

$url = "http://domain.ext/filename.txt";
$result = system_retrieve_file($url, $destination = NULL, $managed = FALSE, $replace = FILE_EXISTS_REPLACE);

By editor , 28 November, 2015

Create and translate a multilingual nodes programmatically.

Tags

  • Drupal 8
  • Code
  • Translation
  • Node

Programmatically create and translate nodes.

Pagination

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