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

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

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

/* poll the SessionNotesAggregator document for its first-generation
   children (ie. the individual Session Notes info documents) */
$SessionNotesDocIDs = $modx->getChildIds($id, 1); /* NB. returns array!! */

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

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

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

/* outputs formatted Session Notes document data */
    $list .= '<li class="liSessionNotesSOSIssue"><a href="';
    $list .= $resource->getTVValue(14); /* TV: sessNotes_SOSIssueLink */
    $list .= '"><strong>';
    $list .= $resource->getTVValue(17); /* TV: sessNotes_SOSIssue */
    $list .= '</strong></a> - ' . "'";
    $list .= $resource->getTVValue(16); /* TV: sessNotes_Artist */
    $list .= ': ';
    $list .= $resource->get('description'); /* document description */
    $list .= "'";
    $list .= ' <span class="spanExampleFile">(';
    $mixPrefix = $resource->getTVValue(19); /* TV: sessNotes_MixPrefix */
    if ($mixPrefix != null) /* only adds mixPrefix if nec */
    {
      $list .= $mixPrefix; /* TV: sessNotes_MixPrefix */
      $list .= ':';
    }
    $list .= '<a href="';
    $list .= $resource->getTVValue(15); /* TV: sessNotes_MixLink */
    $list .= '">MP3</a>&nbsp;';
    $list .= '<div class="WimpyButton_7780205"  data-wimpybutton="';
    $list .= $resource->getTVValue(15); /* TV: sessNotes_MixLink */
    $list .= '"></div>';
    $mixLink2 = $resource->getTVValue(18); /* TV: sessNotes_MixLink2 */
    if ($mixLink2 != null) /* only adds mixLink2 if nec */
    {
      $mixPrefix2 = $resource->getTVValue(20);
                                         /* TV: sessNotes_MixPrefix2 */
      if ($mixPrefix2 != null) /* only adds mixPrefix2 if nec */
      {
        $list .= '; ';
        $list .= $mixPrefix2; /* TV: sessNotes_MixPrefix2 */
        $list .= ':';
      }
      $list .= '<a href="';
      $list .= $mixLink2; /* TV: sessNotes_MixLink2 */
      $list .= '">MP3</a>&nbsp;';
      $list .= '<div class="WimpyButton_7780205"  data-wimpybutton="';
      $list .= $mixLink2; /* TV: sessNotes_MixLink2 */
      $list .= '"></div>';
    }
    $list .= ')</span></li>';

  }
}
if ($issueCount < $articleCounter)
  {
  $list .= '<li><a href="[[~428]]#SessionNotes">Click here to browse all ' . "'" . 'Session Notes' . "'" . ' articles...</a></li>';
  }
$list .= '</ul>';

/* output assembly */
$output .= '<p><strong>' . "'" . 'Session Notes' . "'";
$output .= ' recording features (' . $articleCounter . ' articles):</strong></p>';
$output .= $list;

return $output;