I know the node title, and I want to get node id from the node title, I tried 2 ways but not working properly
1)
$title = arg(2); // get node title from the url
$node = node_load(array('title' => $title));
$nid = $node->nid;
print $nid;
errors are saying that Can only flip STRING and INTEGER values! in DrupalDefaultEntityController->load() , Trying to get property of non-object
2)
$items = entity_load('node', FALSE, array(
'type' => 'article',
'title' => arg(2),
));
but then what I should do ?
Node nid can be only numeric and unique value. $title it is not numeric value it is string that entered by user, $title has no any relations with $node->nid. You can have 10 different nodes with the same title. Also refer please to:
http://api.drupal.org/api/drupal/modules%21node%21node.module/function/node_load/7
http://api.drupal.org/api/drupal/includes!common.inc/function/entity_load/7