Get Entity, Node, Taxonomy from URL Path

Submitted by editor on Wed, 08/24/2016 - 11:42
Question

How to get the element bu url ?

Drupal 8

 

Drupal 7

Get the node
$node = menu_get_object();

Get Path alias
$alias = drupal_get_path_alias();

Get path alias
$alias = drupal_get_path_alias();
$path = drupal_lookup_path("source", $alias);

Get node from path alias
$alias = drupal_get_path_alias();
$path = drupal_lookup_path("source", $alias);
$node = menu_get_object("node", 1, $path);

 

Add new comment