Loading an Entity by its Title

How to load an entity via its title – or other field conditions

$query = new EntityFieldQuery();
$query -> entityCondition('entity_type', 'node') -> propertyCondition('type', 'help_fact') -> propertyCondition('title', $token);
$result = $query -> execute();

This will give a set of NID’s

or

$nodes = node_load_multiple(NULL, array('title' => $token));

will load the whole node.

To grab the first

$node = array_shift($nodes);

done

Leave a comment

Your email address will not be published. Required fields are marked *