/* reset/default variables */
$id = 103; /* resource ID of MixRescueAggregator document */
$issueCounter = 0;
$articleCounter = 0;
if ($issueCount == null) {$issueCount = 10000;}

/* formatting: begin list */
$list = '<ul>';

/* select the MixRescueAggregator document for get() queries */
$resource = $modx->getObject('modResource', $id);

/* poll the MixReviewAggregator document for its first-generation children
   (ie. the individual Mix Rescue info documents) */
$MixRescueDocIDs = $modx->getChildIds($id, 1); /* NB. returns array!! */

/* selects each Mix Rescue document for get() queries in turn,
   then fills data accordingly */
foreach ($MixRescueDocIDs as $key1 => $value1)
{
  $resource = $modx->getObject('modResource', $value1);
  $articleCounter += 1;

/* only shows Mix Rescue documents that are published */
  if ($resource->get('published') == 1 && $issueCounter < $issueCount)
  {

/* increments $issueCounter */
    $issueCounter += 1;

/* outputs formatted Mix Rescue document data */
    $list .= '<li class="liMixRescueSOSIssue">';
    $list .= $resource->getTVValue(9); /* TV: mixResc_Artist */
    $list .= ": ";
    if ($resource->getTVValue(10) != null)
    {
      $list .= "'" . '<a href="';
      $list .= $resource->getTVValue(11); /* TV: mixResc_SOSIssueLink */
      $list .= '">';
      $list .= $resource->getTVValue(10); /* TV: mixResc_Track */
      $list .= '</a>' . "'";
    }
    else
    {
      $list .= '<a href="';
      $list .= $resource->getTVValue(11); /* TV: mixResc_SOSIssueLink */
      $list .= '">';
      $list .= $resource->getTVValue(40); /* TV: mixResc_TrackSpecial */
      $list .= '</a>';
    }
    $list .= ' <span class="spanExampleFile">(';


if ($resource->getTVValue(12) != null) /* TV: mixResc_BeforeMixLink */
  {
    $list .= 'before:<a href="';
    $list .= $resource->getTVValue(12); /* TV: mixResc_BeforeMixLink */
    $list .= '">MP3</a>&nbsp;';
    $list .= '<div class="WimpyButton_7780205"  data-wimpybutton="';
    $list .= $resource->getTVValue(12); /* TV: mixResc_BeforeMixLink */
    $list .= '"></div>; ';
  }

    $list .= 'after:<a href="';
    $list .= $resource->getTVValue(13); /* TV: mixResc_AfterMixLink */
    $list .= '">MP3</a>&nbsp;';
    $list .= '<div class="WimpyButton_7780205"  data-wimpybutton="';
    $list .= $resource->getTVValue(13); /* TV: mixResc_AfterMixLink */
    $list .= '"></div>)';
    $list .= '</span></li>';
  }
}
if ($issueCount < $articleCounter)
  {
  $list .= '<li><a href="[[~428]]#MixRescue">Click here to browse all ' . "'" . 'Mix Rescue' . "'" . ' articles...</a></li>';
  }

$list .= '</ul>';


/* output assembly */
$output .= '<p><strong>' . "'" . 'Mix Rescue' . "'";
$output .= ' reader remixes (' . $articleCounter . ' articles):</strong></p>';
$output .= $list;

return $output;