Skip to main content
edited title
Link
leymannx
  • 18.8k
  • 6
  • 72
  • 126

Get How can I get the path alias from NID (ora node ID or node object)?

Tweeted twitter.com/StackDrupal/status/842877621704802307
improved grammar
Source Link
avpaderno
  • 97.9k
  • 15
  • 164
  • 284

I have a node object, and I am trying to use it to get a given path in Drupal 8.

There was drupal_lookup_path() in Drupal 7 but I'm not seeing any equivalent or documentation for Drupal 8.

What's the new "Drupal" way to get a path from a node object?

Would it be something simple like $node->get('path')?

This seems like a simple question, but I'm just absolutely not finding any documentation on it.

EDIT: I do not want the current path. I want a path based on an arbitrary node object or NID. Notice I do not want the path alias for the current path; I want the path alias for an arbitrary node, given a node object or a node ID.

I have a node object, and I am trying to use it to get a given path in Drupal 8.

There was drupal_lookup_path() in Drupal 7 but I'm not seeing any equivalent or documentation for Drupal 8.

What's the new "Drupal" way to get a path from a node object?

Would it be something simple like $node->get('path')?

This seems like a simple question but I'm just absolutely not finding any documentation on it.

EDIT: I do not want the current path. I want a path based on an arbitrary node object or NID.

I have a node object, and I am trying to use it to get a given path in Drupal 8.

There was drupal_lookup_path() in Drupal 7 but I'm not seeing any equivalent or documentation for Drupal 8.

What's the new "Drupal" way to get a path from a node object?

Would it be something simple like $node->get('path')?

This seems like a simple question, but I'm just absolutely not finding any documentation on it.

Notice I do not want the path alias for the current path; I want the path alias for an arbitrary node, given a node object or a node ID.

added 2 characters in body
Source Link
Jack Ryan
  • 2.3k
  • 4
  • 32
  • 56

I have a path aliasnode object, and I am trying to use it to get a given nidpath in Drupal 8.

There was drupal_lookup_path() in Drupal 7 but I'm not seeing any equivalent or documentation for Drupal 8.

What's the new "Drupal" way to get a path from a node object?

Would it be something simple like $node->get('path')?

This seems like a simple question but I'm just absolutely not finding any documentation on it.

EDIT: I do not want the current path. I want a path based on an arbitrary node object or NID.

I have a path alias, and I am trying to use it to get a given nid in Drupal 8.

There was drupal_lookup_path() in Drupal 7 but I'm not seeing any equivalent or documentation for Drupal 8.

What's the new "Drupal" way to get a path from a node object?

Would it be something simple like $node->get('path')?

This seems like a simple question but I'm just absolutely not finding any documentation on it.

EDIT: I do not want the current path. I want a path based on an arbitrary node object or NID.

I have a node object, and I am trying to use it to get a given path in Drupal 8.

There was drupal_lookup_path() in Drupal 7 but I'm not seeing any equivalent or documentation for Drupal 8.

What's the new "Drupal" way to get a path from a node object?

Would it be something simple like $node->get('path')?

This seems like a simple question but I'm just absolutely not finding any documentation on it.

EDIT: I do not want the current path. I want a path based on an arbitrary node object or NID.

added 96 characters in body
Source Link
Jack Ryan
  • 2.3k
  • 4
  • 32
  • 56
Loading
removed "Drupal" from the title; removed tags from the title; edited tags
Link
avpaderno
  • 97.9k
  • 15
  • 164
  • 284
Loading
Source Link
Jack Ryan
  • 2.3k
  • 4
  • 32
  • 56
Loading