/* reset/default variables */
$id = 550; /* resource ID of BannerAds_LMP document */

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

/* poll the BannerAds_LMP document for its first-generation
   children (ie. the individual banner ad documents) */
$bannerAdIDs = $modx->getChildIds($id, 1); /* NB. returns array!! */

/* select each banner ad document in turn for get() queries
   and build html strings in $bannerBuilder array */

foreach ($bannerAdIDs as $key1 => $value1)
{

/* only shows ads that are published */

$resource = $modx->getObject('modResource', $value1);

  if ($resource->get('published') == 1)
{
$bannerBuilder[$key1] = '<br><a href="' . $resource->get('description') . '">';
$bannerBuilder[$key1] .= '<img alt="' . $resource->get('introtext') . '" ';
$bannerBuilder[$key1] .= 'src="' . $resource->get('content') . '" class="imgBannerAd"></a><br><br>';
}
}

/* turn contents of $bannerBuilder array into placeholders for use by
   bannersRotateMtkLib snippet */
$sortedBanners = array(
   'sortedBanner0' => $bannerBuilder[0],
   'sortedBanner1' => $bannerBuilder[1],
   'sortedBanner2' => $bannerBuilder[2]);

$modx->setPlaceholders($sortedBanners);