node_load() , then accessing the field as a property is the correct way, although I would do it a bit differently to avoid hard-coding locales:
$lang = LANGUAGE_NONE; $node = node_load($nid); $url = $node->url[$lang][0]['value'];
The method that you use to get nid is a particularly clone way to get it; I would focus on refactoring and use EntityFieldQuery and entity_load () instead:
$query = new EntityFieldQuery; $result = $query ->entityCondition('entity_type', 'node') ->propertyCondition('type', $node_type) ->propertyCondition('title', $title) ->execute(); // $result['node'] contains a list of nids where the title matches if (!empty($result['node']) { // You could use node_load_multiple() instead of entity_load() for nodes $nodes = entity_load('node', $result['node']); }
You would like to do this, especially because the name is not a unique property, and if the field appears on objects other than nodes. In this case, you will remove entityCondition() .
user113292
source share