Is there a function in the Drupal API that I can use to get nodes by author ID?
I am trying to create a block that shows the current user a list of their authored pages and I'm having a surprisingly difficult time with it.
Is there a function in the Drupal API that I can use to get nodes by author ID?
I am trying to create a block that shows the current user a list of their authored pages and I'm having a surprisingly difficult time with it.
This is easily done with SQL:
global $user;
$items = array();
$result = db_query("SELECT nid, title FROM {node} WHERE uid = %d", $user->uid);
while ($row = db_fetch_object($result)) {
$items[] = l($row->title, 'node/' . $row->nid);
}
return theme('item_list', $items, NULL, 'ul');
The above code in a custom block should do the trick. Just remember not to cache it.