Need to grab a node’s title or other field value, but all you have access to is the node’s URL?

Here’s a quick way you can look up a node’s title and other fields in Drupal using nothing but its path alias to get what you need:

Node Lookup via Alias

$alias = 'your/url/path/here';
$path = drupal_lookup_path( 'source', $alias );
$node = menu_get_object( 'node', 1, $path );

Node Title:

Now that you have that done, if you want to output the node’s title you can just do this.

$node->title;

Other Node Field:

Or you can grab and output information from other fields attached to your node by using the field’s machine name and grabbing what you want (in this case, the value of the field.)

$node->field_your_fields_machine_name[LANGUAGE_NONE]['0']['value'];

Continue Reading