You are here

function forward_top5_list in Forward 7.2

Same name and namespace in other branches
  1. 5 forward.module \forward_top5_list()
  2. 6 forward.module \forward_top5_list()
  3. 7 forward.module \forward_top5_list()

Theme the top 5 list of users, nodes or comments

1 call to forward_top5_list()
forward_form_submit in ./forward.module
Submit callback function for forward form submit

File

./forward.module, line 1431

Code

function forward_top5_list($query, $base_url, $type) {
  $items = '';
  $query
    ->range(0, 5);
  $result = $query
    ->execute();
  foreach ($result as $item) {
    if ($type == 'user') {
      $items .= '<li>' . l($item->name, 'user/' . $item->uid, array(
        'absolute' => TRUE,
      )) . '</li>';
    }
    elseif ($type == 'comment') {
      $items .= '<li>' . l($item->subject, 'node/' . $item->nid, array(
        'absolute' => TRUE,
        'fragment' => 'comment-' . $item->cid,
      )) . '</li>';
    }
    else {
      $items .= '<li>' . l($item->title, 'node/' . $item->nid, array(
        'absolute' => TRUE,
      )) . '</li>';
    }
  }
  if ($items) {
    $items = '<ul>' . $items . '</ul>';
  }
  return $items;
}