<?
require($_SERVER["DOCUMENT_ROOT"]."/bitrix/header.php");
$APPLICATION->SetTitle("IBlock в таблице");
?><?
// указываем нужный инфоблок
$iblock = 40;
if (CModule::IncludeModule("iblock")) {
$color = "#e2f4ff";
$open_table = true;
$close_table = false;
$hdr = "";
$stru = array();
$i = 0;
$res = CIBlock::GetProperties($iblock, Array("SORT"=>"ASC"));
while ($res_arr = $res->GetNext()) {
$stru[$i++] = $res_arr["ID"];
$hdr .= '<td>'.$res_arr["NAME"].'</td>';
}
$arSelect = Array("ID");
$arFilter = Array("IBLOCK_ID"=>$iblock, "ACTIVE_DATE"=>"Y", "ACTIVE"=>"Y");
$res2 = CIBlockElement::GetList(Array("SORT"=>"ASC", "NAME"=>"ASC"), $arFilter, false, false, $arSelect);
while($ob2 = $res2->GetNext()) {
if ($open_table) {
$open_table = false;
$close_table = true;
echo '<table width="100%" border="1" cellpadding="0" cellspacing="0"><tr><td>Наименование</td>'.$hdr.'</tr>';
}
$tovar = GetIBlockElement($ob2["ID"]);
foreach($tovar["PROPERTIES"] as $arPro) {
$arr_ln[$arPro["ID"]] = $arPro["VALUE"];
}
echo '<tr><td style="background-color:'.$color.'; white-space: nowrap;">'.$tovar["NAME"].'</td>';
$cnt_stru = count($stru);
for ($i = 0; $i < $cnt_stru; $i++) {
echo '<td style="background-color:'.$color.'">'.(($arr_ln[$stru[$i]]=="")?" ":$arr_ln[$stru[$i]]).'</td>';
}
echo '</tr>';
$color = ($color == "#FFFFFF")?"#e2f4ff":"#FFFFFF";
}
if ($close_table) {
echo '</table>';
} else {
echo 'нечего выводить....';
}
}
?><?require($_SERVER["DOCUMENT_ROOT"]."/bitrix/footer.php");?> |