|
хорошо, вот код. я что то не так сделал и у меня не выводит список товаров Скрытый текст |
---|
[CODE] <?
global $USER, $APPLICATION; if ($ELEMENT_SORT_FIELD != '') { } else { $ELEMENT_SORT_FIELD = "name"; } if ($ELEMENT_SORT_ORDER != '') { } else { $ELEMENT_SORT_ORDER = "asc"; }
if (CModule::IncludeModule("iblock")):
IncludeTemplateLangFile(__FILE__);
/************************************************************************* Functions *************************************************************************/
// build tree of the groups function ShowSectionsTree($IBLOCK_ID, $IBlockSection) { global $ID, $APPLICATION; $HTML="";
$arFilter = array ( "IBLOCK_ID"=>$IBLOCK_ID, "GLOBAL_ACTIVE"=>"Y", "CNT_ACTIVE"=>"Y", "LEFT_MARGIN"=>$IBlockSection["LEFT_MARGIN"]+1, "RIGHT_MARGIN"=>$IBlockSection["RIGHT_MARGIN"], );
$rsS = CIBlockSection::GetList(Array("left_margin"=>"asc"), $arFilter, true); while($arS = $rsS->GetNext()) { $s_url = $APPLICATION->GetCurPage()."?SECTION_ID=".$arS["ID"];
$HTML .= '<tr valign="middle"><td><table cellpadding="0" cellspacing="0" border="0"><tr>'; for ($i=1;$i<$arS["DEPTH_LEVEL"]-intval($IBlockSection["DEPTH_LEVEL"]);$i++) { $HTML .= '<td style="width:17px"><font class=tablebodytext> </font></td>'; } $HTML .= '<td><img height="13" src="/bitrix/templates/shop/images/right_down_arrow.gif" width="17" border="0"></td>'; if ($arS["ID"] == $ID) $HTML.= '<td><font class="text"><div style="padding-left:3px"><b><a class="tablebodylink" href="'.$s_url.'">'.$arS["NAME"].'</a></b> ('.$arS["ELEMENT_CNT"].')</div></font></td></tr>'; else $HTML.= '<td><font class="text"><div style="padding-left:3px"><a class="tablebodylink" href="'.$s_url.'">'.$arS["NAME"].'</a> ('.$arS["ELEMENT_CNT"].')</div></font></td></tr>'; $HTML .= '</table></td></tr>'; } return $HTML; }
/************************************************************************* Processing of the received parameters *************************************************************************/
global $$FILTER_NAME; $arrFilter = ${$FILTER_NAME}; $filter_set = count($arrFilter)>0 ? "Y" : "N"; $CACHE_FILTER = ($CACHE_FILTER=="Y") ? "Y" : "N"; if ($CACHE_FILTER=="N" && count($arrFilter)>0) $CACHE_TIME = 0; $bDisplayPanel = ($DISPLAY_PANEL == "Y") ? True : False;
$arrPROPERTY_CODE = is_array($arrPROPERTY_CODE) ? $arrPROPERTY_CODE : array();
if (!(CModule::IncludeModule("sale") && CModule::IncludeModule("catalog"))) $PRICE_CODE = "";
/************************************************************************* Processing of the Buy link *************************************************************************/
if (($_REQUEST["action"] == "ADD_TO_BASKET" || $_REQUEST["action"] == "BUY") && IntVal($_REQUEST["price_id"])>0) { if ($_REQUEST["link"]=="N") $arRewriteFields = array("DETAIL_PAGE_URL"=>""); Add2Basket($_REQUEST["price_id"], 1, $arRewriteFields);
if ($_REQUEST["action"] == "BUY") LocalRedirect($BASKET_URL); // LocalRedirect("/personal/cart/"); else LocalRedirect($APPLICATION->GetCurPageParam("", array("price_id", "action", "link"))); }
/************************************************************************* Work with cache *************************************************************************/
$obCache = new CPHPCache; $CACHE_ID = __FILE__.md5(serialize($arParams).$USER->GetGroups().CDBResult::NavStringForCache($PAGE_ELEMENT_COUNT)); if($obCache->InitCache($CACHE_TIME, $CACHE_ID, "/")) { $arVars = $obCache->GetVars(); $SECTION_ID = $arVars["SECTION_ID"]; $IBLOCK_ID = $arVars["IBLOCK_ID"]; $ELEMENT_NAME = $arVars["ELEMENT_NAME"]; $IBLOCK_TYPE = $arVars["IBLOCK_TYPE"]; $arrPath = $arVars["arrPath"]; } else { $arSection = GetIBlockSection($SECTION_ID); $SECTION_ID = $arSection["ID"]; $IBLOCK_ID = $arSection["IBLOCK_ID"];
$arIBlock = GetIBlock($IBLOCK_ID); $IBLOCK_TYPE = $arIBlock["IBLOCK_TYPE_ID"];
$arrPath = array(); $rsPath = GetIBlockSectionPath($IBLOCK_ID, $SECTION_ID); while($arPath=$rsPath->GetNext()) $arrPath[] = array("ID" => $arPath["ID"], "NAME" => $arPath["NAME"]);
$arIblockType = CIBlockType::GetByIDLang($IBLOCK_TYPE, LANGUAGE_ID); $ELEMENT_NAME = $arIblockType["ELEMENT_NAME"]; }
if (intval($SECTION_ID) > 0):
if ($bDisplayPanel) CIBlock::ShowPanel($IBLOCK_ID, 0, $SECTION_ID, $IBLOCK_TYPE); if (is_array($arrPath)) { while(list($key, $arS) = each($arrPath)) { if ($SECTION_ID==$arS["ID"]) $SECTION_NAME = $arS["NAME"]; $APPLICATION->AddChainItem($arS["NAME"], $APPLICATION->GetCurPage()."?SECTION_ID=".$arS["ID"]); } } $APPLICATION->SetTitle($SECTION_NAME);
if($obCache->StartDataCache()):
/**************************************************************** HTML form ****************************************************************/
$arrPrice = ""; // if price type code specified if (strlen($PRICE_CODE)>0 && CModule::IncludeModule("sale") && CModule::IncludeModule("catalog")) { $arrPrice = array(); $rsPrice = CCatalogGroup::GetList($v1, $v2, array("NAME" => $PRICE_CODE));
while($arPrice = $rsPrice->Fetch()) $arrPrice[$arPrice["NAME"]] = array("ID" => $arPrice["ID"], "TITLE" => $arPrice["NAME_LANG"]); } else $PRICE_CODE = "";
/************************************ Group tree ************************************/ $HTML = ShowSectionsTree($IBLOCK_ID, $arSection); if (strlen($HTML)>0): ?><table border="0" cellpadding="1" cellspacing="0" width="100%"><?=$HTML?></table><? endif;
/************************************ Element table ************************************/
// list the element fields that will be used in selection $arSelect = array( "ID", "IBLOCK_ID", "IBLOCK_SECTION_ID",
"NAME", "PREVIEW_TEXT", "PREVIEW_TEXT_TYPE", "PREVIEW_PICTURE", "DETAIL_TEXT", "DETAIL_TEXT_TYPE", "DETAIL_PICTURE", "DETAIL_PAGE_URL" ); if (is_array($arrPrice) && count($arrPrice)>0) $arSelect[] = "CATALOG_GROUP_".$arrPrice[$PRICE_CODE]["ID"];
// adding values to the filter $arrFilter["ACTIVE"] = "Y"; $arrFilter["SECTION_ID"] = $SECTION_ID; $arrFilter["INCLUDE_SUBSECTIONS"] = "Y"; # $arrFilter["ID"] = "asc";
if ($rsElements = GetIBlockElementListEx($IBLOCK_TYPE, $IBLOCK_ID, false, array($ELEMENT_SORT_FIELD => $ELEMENT_SORT_ORDER, "ID" => "DESC"), false, $arrFilter, $arSelect)): $rsElements->NavStart($PAGE_ELEMENT_COUNT); $count = intval($rsElements->SelectedRowsCount());
if ($count<=0 && $filter_set=="Y"): echo ShowNote(GetMessage("CATALOG_ELEMENT_NOT_FOUND")); else: ?><? //echo $rsElements->NavPrint($ELEMENT_NAME)?> <?
if ($obElement = $rsElements->GetNextElement()):
$arElement = $obElement->GetFields(); $arProperty = $obElement->GetProperties(); ?> <? if(CModule::IncludeModule('catalog')) { $arFilter = Array("ID" => "22"); $lastuse = CCatalogImport::GetList(Array(), $arFilter, false); $ar = $lastuse->Fetch(); # echo '<P align="right">Актуализировано '.$ar['LAST_USE_FORMAT'].'</P>'; } ?> <table cellspacing=0 cellpadding=0 border=0 class="tableborder" width="100%"> <tr> <td width="100%"> <table cellspacing=0 cellpadding=5 width="100%"> <tr> <td bordercolor="0" class="tablebody_dgreen"><font class="tableheadtextwhite"><?=GetMessage("CATALOG_TITLE")?></font> <a href="/catalog/pricelist/section.php?SECTION_ID=<? echo $SECTION_ID; ?>&ELEMENT_SORT_FIELD=name&ELEMENT_SORT_ORDER=asc" title="Сортировать по возрастанию"><img src="/bitrix/templates/main_fix_shop/images/sort_up.gif" width="9" height="9" border="0" alt="ASC"></a> <a href="/catalog/pricelist/section.php?SECTION_ID=<? echo $SECTION_ID; ?>&ELEMENT_SORT_FIELD=name&ELEMENT_SORT_ORDER=desc" title="Сортировать по убыванию"><img src="/bitrix/templates/main_fix_shop/images/sort_down.gif" width="9" height="9" border="0" alt="DESC"></a></td> <? // properties if (is_array($arrPROPERTY_CODE) && count($arrPROPERTY_CODE)>0): reset($arrPROPERTY_CODE); foreach($arrPROPERTY_CODE as $pid): ?> <td class="tablebody_dgreen" align="center"><font class="tableheadtextwhitesmall"><?=$arProperty[$pid]["NAME"]?></font></td> <? endforeach; endif; ?> <? // price if (strlen($PRICE_CODE)>0 && is_array($arrPrice) && count($arrPrice)>0): ?> <td class="tablebody_dgreen" align="center"><font class="tableheadtextwhite"><? //=$arrPrice[$PRICE_CODE]["TITLE"]?>Цена</font><BR> <a href="/catalog/pricelist/section.php?SECTION_ID=<? echo $SECTION_ID; ?>&ELEMENT_SORT_FIELD=CATALOG_PRICE_1&ELEMENT_SORT_ORDER=asc" title="Сортировать по возрастанию"><img src="/bitrix/templates/main_fix_shop/images/sort_up.gif" width="9" height="9" border="0" alt="ASC"></a> <a href="/catalog/pricelist/section.php?SECTION_ID=<? echo $SECTION_ID; ?>&ELEMENT_SORT_FIELD=CATALOG_PRICE_1&ELEMENT_SORT_ORDER=desc" title="Сортировать по убыванию"><img src="/bitrix/templates/main_fix_shop/images/sort_down.gif" width="9" height="9" border="0" alt="DESC"></a></td> <td class="tablebody_dgreen"> </td> <td class="tablebody_dgreen"><font class="tableheadtext"> </font></td> <td class="tablebody_dgreen"> </td> <? endif; ?> </tr> <? do{ $arElement = $obElement->GetFields(); $arProperty = $obElement->GetProperties(); $link = "N"; // flag shows if element has or not detailed description ?> <tr> <td class="tablebody_lgreen" width="90%"><font class="tablebodytext"><?
if (intval($arElement["PREVIEW_PICTURE"])>0 || strlen($arElement["PREVIEW_TEXT"])>0 || strlen($arElement["DETAIL_TEXT"])>0 || intval($arElement["PREVIEW_PICTURE"])>0):
$link = "Y";
?><a id="nu_dark" href="<?=$arElement["DETAIL_PAGE_URL"]?>"><?=$arElement["NAME"]?></a><?
else:
//echo $arElement["NAME"]; //echo $PRICE_CODE; ?><a id="nu" href="<?=$arElement["DETAIL_PAGE_URL"]?>"><?=$arElement["NAME"]?></a><? endif; ?></font></td> <? // properties if (is_array($arrPROPERTY_CODE) && count($arrPROPERTY_CODE)>0): reset($arrPROPERTY_CODE); foreach($arrPROPERTY_CODE as $pid): ?> <td class="tablebody_lgreen" align="center"><font class="tablebodytext"> <? // echo (is_array($arProperty[$pid]["VALUE"])) ? implode("<br>",$arProperty[$pid]["VALUE"]) : $arProperty[$pid]["VALUE"] ?> <? if ($arProperty[$pid]["VALUE"] == '+') { echo '<IMG title="Есть в наличии" alt="Есть в наличии" src="/bitrix/templates/main_fix_shop/images/positive_flag.gif" height=9 width=8 border=0 >'; } ?> </font></td> <? endforeach; endif; ?>
<? // price if (strlen($PRICE_CODE)>0 && is_array($arrPrice) && count($arrPrice)>0):
// goods parameters $trace_quantity = $arElement["CATALOG_QUANTITY_TRACE"]; // monitor quantity in stock $quantity = intval($arElement["CATALOG_QUANTITY"]); // quantity in stock $price_value = $arElement["CATALOG_PRICE_".$arrPrice[$PRICE_CODE]["ID"]]; // price
$price_currency = $arElement["CATALOG_CURRENCY_".$arrPrice[$PRICE_CODE]["ID"]]; // currency $can_access = $arElement["CATALOG_CAN_ACCESS_".$arrPrice[$PRICE_CODE]["ID"]]; // if the price can be viewed? $can_buy = $arElement["CATALOG_CAN_BUY_".$arrPrice[$PRICE_CODE]["ID"]]; // if the price can be used for ordering? $price_id = $arElement["CATALOG_PRICE_ID_".$arrPrice[$PRICE_CODE]["ID"]]; // goods price ID
$arDiscounts = CCatalogDiscount::GetDiscountByProduct( $arElement["ID"], $GLOBALS["USER"]->GetUserGroupArray(), "N" ); // getting discount of product $discountPrice = CCatalogProduct::CountPriceWithDiscount($price_value, $price_currency, $arDiscounts); // calculate price with discount ?> <td class="tablebody_lgreen" align="right"><font class="tablebodytext" nowrap><nobr><? if ($can_access=="Y"): if($price_value != 0) { if($discountPrice < $price_value) echo '<b><s>'.FormatCurrency($price_value, $price_currency).'</s><br><font color="red">'.FormatCurrency($discountPrice, $price_currency); else // echo '<font color="#336633"><b>'.FormatCurrency($price_value, $price_currency); echo '<font color="#336633"><b>'.$price_value; } else { echo '<font color="#336633"><b>Звоните!'; } ?></b></font><? endif; ?> </font></td> <td class="tablebody_lgreen" nowrap><b><? $arIBlockElement = GetIBlockElement($arElement["ID"]); $db_res = GetCatalogProductPrice($arElement["ID"], 5); if (($arIBlockElement['PROPERTIES']['xt']['VALUE'] == '+') or ($arIBlockElement['PROPERTIES']['bk']['VALUE'] == '+') or ($arIBlockElement['PROPERTIES']['mk']['VALUE'] == '+')) { if ($db_res["PRICE"] != 0) echo "<a id=nu_red title='Специальная цена!' href = \"javascript:window.open('/catalog/pricelist/special.php?price=".$db_res["PRICE"]."', 'SpecialPrice', ' top=300, left=300, toolbar=0, location=0, menubar=0, width=250, height=210'); void(0)\">".$db_res["PRICE"]."</a>"; } ?> </b> </td> <td class="tablebody_lgreen" nowrap><font class="tablebodytext"><? if ($can_buy=="Y"): if ($trace_quantity!="Y" || ($trace_quantity=="Y" && $quantity>0)): ?><a href="javascript: alert('<?=GetMessage("CATALOG_ADD_TO_BASKET_NOTIFY")?>'); window.location='<?=$APPLICATION->GetCurPageParam("price_id=".$price_id."&action=ADD_TO_BASKET&link=".$link, array("price_id", "action", "link"))?>'" class="smalltext"><IMG src="/images/basket.gif" height=16 width=16 border=0 ></a></td> <td class="tablebody_lgreen" align="center"> <b><a href="<?=$APPLICATION->GetCurPageParam("price_id=".$price_id. "&action=BUY&link=".$link, array("price_id", "action", "link")) ?>" class="text">купить дешевле</a></b><? else: ?><font class="smalltext"><?=GetMessage("CATALOG_NOT_AVAILABLE")?></font><? endif; endif; ?> </td> <?endif;?> </tr> <? } while ($obElement = $rsElements->GetNextElement()); ?> </table> </td> </tr> </table> <?echo $rsElements->NavPrint($ELEMENT_NAME)?> <? endif; //if ($obElement = $rsElements->GetNextElement()): endif;//if ($count<=0 && $filter_set=="Y"): endif; $obCache->EndDataCache(array( "IBLOCK_ID" => $IBLOCK_ID, "IBLOCK_TYPE" => $IBLOCK_TYPE, "SECTION_ID" => $SECTION_ID, "ELEMENT_NAME" => $ELEMENT_NAME, "arrPath" => $arrPath, )); endif; else: ShowError(GetMessage("CATALOG_SECTION_NOT_FOUND")); @define("ERROR_404", "Y"); endif; endif; ?> <div style="height:400px"> </div>[/CODE] |
|