You are here

function simplenews_recent_newsletters in Simplenews 7

Same name and namespace in other branches
  1. 5 simplenews.module \simplenews_recent_newsletters()
  2. 6.2 simplenews.module \simplenews_recent_newsletters()
  3. 6 simplenews.module \simplenews_recent_newsletters()
  4. 7.2 simplenews.module \simplenews_recent_newsletters()

Create a list of recent newsletters issues.

@todo Replace this list by a View.

Parameters

integer $tid: The newsletter category id.

integer $count: The number of newsletters.

Related topics

1 call to simplenews_recent_newsletters()
template_preprocess_simplenews_block in ./simplenews.module
Process variables to format the simplenews block.

File

./simplenews.module, line 1721
Simplenews node handling, sent email, newsletter block and general hooks

Code

function simplenews_recent_newsletters($tid, $count = 5) {
  $titles = '';
  $query = db_select('node', 'n');
  $query
    ->innerJoin('simplenews_newsletter', 'sn', 'n.nid = sn.nid');
  $query
    ->fields('n', array(
    'nid',
    'title',
  ))
    ->condition('sn.tid', $tid)
    ->condition('n.status', NODE_PUBLISHED)
    ->condition('sn.status', SIMPLENEWS_STATUS_SEND_NOT, '<>')
    ->orderBy('n.created', 'DESC')
    ->range(0, $count);
  $titles = array();
  foreach ($query
    ->execute() as $item) {
    $titles[$item->nid]['data'] = l($item->title, 'node/' . $item->nid);
  }
  return $titles;
}