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

Node

By editor , 13 September, 2017

Render a Node or an Entity

Tags

  • Drupal 8
  • Code
  • Views
  • Node
  • Field
  • Drupal 9

On drupal 8 every elements (almost) are an entity, as any entity you can render a node.

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

Update a node / Entity programmatically in Drupal 8

Tags

  • Drupal 8
  • Code
  • Node

Update a node:

Example 1 : Update title
$node = \Drupal\node\Entity\Node::load($nid);
$node->setTitle('The new Title')
$node->save();

By editor , 4 December, 2015

Create a node With date field

Tags

  • Drupal 8
  • Code
  • Node

It is same as normal node creation but must be in format "Y-m-d" (YYYY-MM-DD)

Example:

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 , 28 November, 2015

Create and translate a multilingual nodes programmatically.

Tags

  • Drupal 8
  • Code
  • Translation
  • Node

Programmatically create and translate nodes.

By editor , 28 November, 2015

Translate a node programmatically

Tags

  • Drupal 8
  • Code
  • Translation
  • Node

Exemples:

$translation = $entity->getTranslation('de');

By editor , 13 November, 2015

Create a node programmatically in Drupal 8

Tags

  • Drupal 8
  • Code
  • Node

Here an example for create node programmatically in Drupal 8

Node

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