Created
August 29, 2017 12:03
-
-
Save Pum-purum/70fa564b6d7c71a232bfe889017f0d46 to your computer and use it in GitHub Desktop.
Умный фильтр Битрикс
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
if (CModule::IncludeModule("iblock")) | |
{ | |
$arFilter = array( | |
"ACTIVE" => "Y", | |
"GLOBAL_ACTIVE" => "Y", | |
"IBLOCK_ID" => $arParams["IBLOCK_ID"], | |
); | |
if(strlen($arResult["VARIABLES"]["SECTION_CODE"])>0) | |
{ | |
$arFilter["CODE"] = $arResult["VARIABLES"]["SECTION_CODE"]; | |
} | |
elseif($arResult["VARIABLES"]["SECTION_ID"]>0) | |
{ | |
$arFilter["ID"] = $arResult["VARIABLES"]["SECTION_ID"]; | |
} | |
$obCache = new CPHPCache; | |
if($obCache->InitCache(36000, serialize($arFilter), "/iblock/catalog")) | |
{ | |
$arCurSection = $obCache->GetVars(); | |
} | |
else | |
{ | |
$arCurSection = array(); | |
$dbRes = CIBlockSection::GetList(array(), $arFilter, false, array("ID")); | |
$dbRes = new CIBlockResult($dbRes); | |
if(defined("BX_COMP_MANAGED_CACHE")) | |
{ | |
global $CACHE_MANAGER; | |
$CACHE_MANAGER->StartTagCache("/iblock/catalog"); | |
if ($arCurSection = $dbRes->GetNext()) | |
{ | |
$CACHE_MANAGER->RegisterTag("iblock_id_".$arParams["IBLOCK_ID"]); | |
} | |
$CACHE_MANAGER->EndTagCache(); | |
} | |
else | |
{ | |
if(!$arCurSection = $dbRes->GetNext()) | |
$arCurSection = array(); | |
} | |
$obCache->EndDataCache($arCurSection); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
В вызове умного фильтра прописать в параметре "SECTION_ID" => $arCurSection["ID"],