You are here

function simplenews_recent_newsletters in Simplenews 7.2

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 simplenews.module \simplenews_recent_newsletters()

Create a list of recent newsletters issues.

@todo Replace this list by a View.

Parameters

integer $newsletter_id: The newsletter 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 1868
Simplenews node handling, sent email, newsletter block and general hooks

Code

function simplenews_recent_newsletters($newsletter_id, $count = 5) {
  $query = new EntityFieldQuery();
  $result = $query
    ->entityCondition('entity_type', 'node')
    ->propertyCondition('status', NODE_PUBLISHED)
    ->fieldCondition(variable_get('simplenews_newsletter_field', 'simplenews_newsletter'), 'target_id', $newsletter_id)
    ->fieldCondition(variable_get('simplenews_issue_status_field', 'simplenews_issue_status'), 'value', SIMPLENEWS_STATUS_SEND_NOT, '<>')
    ->propertyOrderBy('created', 'DESC')
    ->range(0, $count)
    ->execute();
  $titles = array();
  if (!empty($result['node'])) {
    foreach (node_load_multiple(array_keys($result['node'])) as $item) {
      $titles[$item->nid]['data'] = l($item->title, 'node/' . $item->nid);
    }
  }
  return $titles;
}