Skip to main content
added 4 characters in body
Source Link
Maciej Zgadzaj
  • 2.6k
  • 15
  • 25

Use following code snippet to get node field values

This is used to get node id from url

$nid = \Drupal::routeMatch()->getRawParameter($node_id);

To load node data using nid

$node = \Drupal::entityManagerentityTypeManager()->getStorage('node')->load($nid);

This is used to get field value.

$terms = $node->get('field_Name')->getValue();  

This is used to get node title.

$product_name = $node->getTitle();

Use following code snippet to get node field values

This is used to get node id from url

$nid = \Drupal::routeMatch()->getRawParameter($node_id);

To load node data using nid

$node = \Drupal::entityManager()->getStorage('node')->load($nid);

This is used to get field value.

$terms = $node->get('field_Name')->getValue();  

This is used to get node title.

$product_name = $node->getTitle();

Use following code snippet to get node field values

This is used to get node id from url

$nid = \Drupal::routeMatch()->getRawParameter($node_id);

To load node data using nid

$node = \Drupal::entityTypeManager()->getStorage('node')->load($nid);

This is used to get field value.

$terms = $node->get('field_Name')->getValue();  

This is used to get node title.

$product_name = $node->getTitle();
added 4 characters in body
Source Link
Adrian Cid Almaguer
  • 18.5k
  • 14
  • 79
  • 133

Use following code snippet to get node field values

This is used to get node id from url

$nid = \Drupal::routeMatch()->getRawParameter($node_id);

To load node data using nid

$node = \Drupal::entityManager()->getStorage('node')->load($nid);

This is used to get field value.

$terms = $node->get('field_Name')->getValue();

$terms = $node->get('field_Name')->getValue();  

This is used to get node title.

$product_name = $node->getTitle();

Use following code snippet to get node field values

This is used to get node id from url

$nid = \Drupal::routeMatch()->getRawParameter($node_id);

To load node data using nid

$node = \Drupal::entityManager()->getStorage('node')->load($nid);

This is used to get field value.

$terms = $node->get('field_Name')->getValue();

This is used to get node title.

$product_name = $node->getTitle();

Use following code snippet to get node field values

This is used to get node id from url

$nid = \Drupal::routeMatch()->getRawParameter($node_id);

To load node data using nid

$node = \Drupal::entityManager()->getStorage('node')->load($nid);

This is used to get field value.

$terms = $node->get('field_Name')->getValue();  

This is used to get node title.

$product_name = $node->getTitle();
Source Link

Use following code snippet to get node field values

This is used to get node id from url

$nid = \Drupal::routeMatch()->getRawParameter($node_id);

To load node data using nid

$node = \Drupal::entityManager()->getStorage('node')->load($nid);

This is used to get field value.

$terms = $node->get('field_Name')->getValue();

This is used to get node title.

$product_name = $node->getTitle();