2012-05-13 57 views
0

我知道結題,我想從結題得到節點ID,我嘗試過2種方法,但不能正常工作在drupal 7中,如何從節點標題獲取節點ID?

1)

$title = arg(2); // get node title from the url 
$node = node_load(array('title' => $title));  
$nid = $node->nid; 
print $nid; 

錯誤是說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), 
    )); 

但後來我應該怎麼辦呢?

+0

通常,精氨酸(1)是節點ID(節點/ 16 /編輯)。這裏,arg(2)是'編輯'。 –

回答