Monday, 14 March 2016

Drupal 8 - Get Path Alias

Here is the code to get the url alias for particular page using Drupal 8

$input_path_alias = \Drupal::service('path.alias_manager')->getAliasByPath("/node/1", 'en');

Note: Do not forget to include slash at front ("/node/1")

I hope this helps.

No comments:

Post a Comment

PHP Codesniffer - Ignore warning errors

 Use below command to ignore warnings while generating report. phpcs -n /path_to_directory/ The above command will result only errors and ig...