8.3.x node.module node_get_recent($number = 10)
8.0.x node.module node_get_recent($number = 10)
8.1.x node.module node_get_recent($number = 10)
8.2.x node.module node_get_recent($number = 10)
8.4.x node.module node_get_recent($number = 10)
7.x node.module node_get_recent($number = 10)

Finds the most recently changed nodes that are available to the current user.


$number: (optional) The maximum number of nodes to find. Defaults to 10.

Return value

An array of node entities or an empty array if there are no recent nodes visible to the current user.

2 calls to node_get_recent()
hook_block_view in modules/block/block.api.php
Return a rendered or renderable view of a block.
node_block_view in modules/node/node.module
Implements hook_block_view().


modules/node/node.module, line 2312
The core that allows content to be submitted to the site. Modules and scripts may programmatically submit nodes using the usual form API pattern.


function node_get_recent($number = 10) {
  $query = db_select('node', 'n');

  if (!user_access('bypass node access')) {
    // If the user is able to view their own unpublished nodes, allow them to
    // see these in addition to published nodes. Check that they actually have
    // some unpublished nodes to view before adding the condition.
    if (user_access('view own unpublished content') && $own_unpublished = db_query('SELECT nid FROM {node} WHERE uid = :uid AND status = :status', array(':uid' => $GLOBALS['user']->uid, ':status' => NODE_NOT_PUBLISHED))->fetchCol()) {
        ->condition('n.status', NODE_PUBLISHED)
        ->condition('n.nid', $own_unpublished, 'IN')
    else {
      // If not, restrict the query to published nodes.
      $query->condition('n.status', NODE_PUBLISHED);
  $nids = $query
  ->fields('n', array('nid'))
    ->orderBy('n.changed', 'DESC')
    ->range(0, $number)

  $nodes = node_load_multiple($nids);

  return $nodes ? $nodes : array();