3

Does the node_load() does not return the node url alias in the node object or am I missing something.

I know one way of getting the url alias/path is using the drupal_get_path_alias("node/NODE_ID"), however I was hoping the object return by node_load should contain node url alias as well.

1 Answer 1

4

No, the URL alias is not a field nor entity property, and it doesn't get added to the node object when it's loaded.

It would be trivial to add that data though, using hook_node_load()

function MYMODULE_node_load($nodes, $types) {
  foreach ($nodes as $node) {
    $node->url_alias = url("node/$node->nid");
  } 
}
0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.