You are here

function node_title_list in Drupal 7

Same name and namespace in other branches
  1. 8 core/modules/node/node.module \node_title_list()
  2. 4 modules/node.module \node_title_list()
  3. 5 modules/node/node.module \node_title_list()
  4. 6 modules/node/node.module \node_title_list()
  5. 9 core/modules/node/node.module \node_title_list()

Gathers a listing of links to nodes.

Parameters

$result: A database result object from a query to fetch node entities. If your query joins the {node_comment_statistics} table so that the comment_count field is available, a title attribute will be added to show the number of comments.

$title: A heading for the resulting list.

Return value

A renderable array containing a list of linked node titles fetched from $result, or FALSE if there are no rows in $result.

3 calls to node_title_list()
blog_block_view in modules/blog/blog.module
Implements hook_block_view().
forum_block_view_pre_render in modules/forum/forum.module
Render API callback: Lists nodes based on the element's #query property.
statistics_block_view in modules/statistics/statistics.module
Implements hook_block_view().

File

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

Code

function node_title_list($result, $title = NULL) {
  $items = array();
  $num_rows = FALSE;
  foreach ($result as $node) {
    $items[] = l($node->title, 'node/' . $node->nid, !empty($node->comment_count) ? array(
      'attributes' => array(
        'title' => format_plural($node->comment_count, '1 comment', '@count comments'),
      ),
    ) : array());
    $num_rows = TRUE;
  }
  return $num_rows ? array(
    '#theme' => 'item_list__node',
    '#items' => $items,
    '#title' => $title,
  ) : FALSE;
}