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.

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");
  } 
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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