AddEventHandler("main", "OnEndBufferContent", "ShowBannerInsideNews"); function ShowBannerInsideNews(&$content){ if (CModule::IncludeModule("advertising")){ if (strpos($content, '#BANNER_INSIDE_INSTS_LIST#') !== false){ $crop_content = explode('<span>#BANNER_INSIDE_INSTS_LIST#</span>',$content); $aEarsAdv = array(); for($i=0,$j=1; $i<$j; $i++){ $sAdv = CAdvBanner::GetRandom('insts_list'); if(!empty($sAdv)){ $AdvWeightSort[] = $sAdv['WEIGHT']; $AdvIdSort[] = $sAdv['ID']; $aEarsAdv[] = $sAdv; $j++; } else break; } array_multisort($AdvWeightSort,SORT_ASC,$AdvIdSort,SORT_ASC,$aEarsAdv); $content = null; foreach($crop_content as $croped_key=>$croped){ $banner = CAdvBanner::GetHTML($aEarsAdv[$croped_key]); $content .= $croped.$banner; } } } }