Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

drupal 8 get node from path alias

// Get node from path alias.
$path = Drupal::service('path.alias_manager')->getPathByAlias('/this-is-the-alias');

if(preg_match('/node/(d+)/', $path, $matches)) {
  $node = Drupal
odeEntityNode::load($matches[1]);
}

// Path alias manager service has been change to 'path_alias.manager' on later version.
$path = Drupal::service('path_alias.manager')->getPathByAlias('/this-is-the-alias');
Comment

drupal 9 node get url alias

Drupal 8
$alias = Drupal::service('path.alias_manager')->getAliasByPath('/node/'.$nid);

Drupal 9
$alias = Drupal::service('path_alias.manager')->getAliasByPath('/node/'.$nid);
Comment

PREVIOUS NEXT
Code Example
Javascript :: angular filter array of objects 
Javascript :: js decode base64 
Javascript :: sum two objects javascript 
Javascript :: filter falsy values js 
Javascript :: javascript average function 
Javascript :: add commas to a number javascript 
Javascript :: send data through routes in react 
Javascript :: checkbox on click jquery 
Javascript :: json fetch data doest show 
Javascript :: (node:2736) DeprecationWarning: collection.ensureIndex is deprecated. Use createIndexes instead. 
Javascript :: vuex v-model 
Javascript :: javascript show localstorage size 
Javascript :: run a loop inside a console.log no blank line 
Javascript :: axios configure base url 
Javascript :: last position of array javascript 
Javascript :: first letter capital in javascript 
Javascript :: remove white space from string in js 
Javascript :: http get request js 
Javascript :: js string check case 
Javascript :: get the last item in object javascript 
Javascript :: vue data 
Javascript :: how to tell c++ a function exists before calling 
Javascript :: rounding off in javascript 
Javascript :: node js run bat file 
Javascript :: js remove query param from url 
Javascript :: check if a string contains digits js 
Javascript :: jquery append 
Javascript :: javascript infinity loop 
Javascript :: socket.io with express 
Javascript :: call function in javascript from html 
ADD CONTENT
Topic
Content
Source link
Name
8+8 =