You are here

function theme_scs_newsletter_output in Simplenews Content Selection 6.2

Same name and namespace in other branches
  1. 7 scs.theme.inc \theme_scs_newsletter_output()

Theme a complete newsletter.

1 theme call to theme_scs_newsletter_output()
_scs_create_newsletter in ./scs.module
Newsletter creator function

File

./scs.theme.inc, line 142
Select Drupal content to create a newsletter

Code

function theme_scs_newsletter_output($options) {
  $body = '';
  $titles = array();
  $nodes = $options['nodes'];
  $format = variable_get('scs_format', 'plain');
  if (count($nodes) == 1) {
    $nodes = array_shift($nodes);

    // Node information
    foreach ($nodes as $node) {
      if ($options['toc']) {
        if ($format == 'plain') {
          $titles[] = $node->title;
        }
        else {
          $titles[] = '<a href="#node_' . $node->nid . '">' . $node->title . '</a>';
        }
      }
      $body .= theme(array(
        'scs_node_output__' . $options['type'],
        'scs_node_output',
      ), $node);
    }
  }
  else {
    foreach ($nodes as $region => $elements) {
      $regioncontent = '';
      foreach ($elements as $node) {
        if ($format == 'plain') {
          $titles[] = $node->title;
        }
        else {
          $titles[] = '<a href="#node_' . $node->nid . '">' . $node->title . '</a>';
        }
        $regioncontent .= theme(array(
          'scs_node_output__region-' . $region . '_' . $options['type'],
          'scs_node_output__region_' . $region,
          'scs_node_output__' . $options['type'],
          'scs_node_output',
        ), $node);
      }
      $body .= theme(array(
        'scs_region_output__' . $region,
        'scs_region_output',
      ), $region, $regioncontent);
    }
  }

  // ToC (if required)
  if ($options['toc']) {
    $body = theme('scs_node_titles', $titles) . $body;
  }

  // Complete newsletter body
  return $body;
}