B
B
bionkin2016-05-19 10:05:34
1C-Bitrix
bionkin, 2016-05-19 10:05:34

Bitrix. How to display a smart filter only at the 3rd level of group nesting (Where there are products only)?

I use the complex component Catalog.
The following directory structure is needed:
Group1(first nesting)
-Group1.1(second nesting)
-Group1.2(second nesting)
Group2(first nesting)
-Group2.1(second nesting)
-Group2.2(second nesting)
I go to the directory , I see the section Group1 (first nesting) . It is displayed in the sections.php file via bitrix:catalog.section.list. Everything is fine here, I see a list of groups of the first nesting, go to Group1 (first nesting):
Removed the display of nested elements (i.e. products are not displayed at this level). At the second level, the section.php file is connected; bitrix:catalog.section.list is first connected in it, everything is fine here, I see the -Group1.1 itself (the second nesting).
Further on the same page, a smart filter is displayed, but since I do not display the products on this page, I do not need a filter on the second nesting level. How to make the filter display only where there are goods, i.e. starting from the 3rd nesting level?
I attach the section.php file in the source code

<?if(!defined("B_PROLOG_INCLUDED") || B_PROLOG_INCLUDED!==true)die();?>
<?$APPLICATION->IncludeComponent(
  "bitrix:catalog.section.list",
  "",
  Array(
    "IBLOCK_TYPE" => $arParams["IBLOCK_TYPE"],
    "IBLOCK_ID" => $arParams["IBLOCK_ID"],
    "SECTION_ID" => $arResult["VARIABLES"]["SECTION_ID"],
    "SECTION_CODE" => $arResult["VARIABLES"]["SECTION_CODE"],
    "DISPLAY_PANEL" => "N",
    "CACHE_TYPE" => $arParams["CACHE_TYPE"],
    "CACHE_TIME" => $arParams["CACHE_TIME"],
    "CACHE_GROUPS" => $arParams["CACHE_GROUPS"],
    "TOP_DEPTH" => 1,
    "SECTION_URL" => $arResult["FOLDER"].$arResult["URL_TEMPLATES"]["section"],
  ),
  $component
);?>
<br />
<?dump($arResult["SECTION"]);?>

<div class="row">
<?
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);
    }
    ?>
<div class="col-xs-12 col-sm-4 col-md-4 col-lg-3">	
   <?$APPLICATION->IncludeComponent(
      "bitrix:catalog.smart.filter",
      "visual_vertical",
      Array(
         "PRICE_CODE" => array(0=>"BASE",),
         "IBLOCK_TYPE" => $arParams["IBLOCK_TYPE"],
         "IBLOCK_ID" => $arParams["IBLOCK_ID"],
         "SECTION_ID" => $arCurSection['ID'],
         "FILTER_NAME" => $arParams["FILTER_NAME"],
         "CACHE_TYPE" => $arParams["CACHE_TYPE"],
         "CACHE_TIME" => $arParams["CACHE_TIME"],
         "CACHE_GROUPS" => $arParams["CACHE_GROUPS"],
         "SAVE_IN_SESSION" => "N",
         "XML_EXPORT" => "Y",
         "SECTION_TITLE" => "NAME",
         "SECTION_DESCRIPTION" => "DESCRIPTION",
         'HIDE_NOT_AVAILABLE' => $arParams["HIDE_NOT_AVAILABLE"],
         "TEMPLATE_THEME" => $arParams["TEMPLATE_THEME"]
      ),
      $component,
      array('HIDE_ICONS' => 'Y')
   );?>
   </div>
<?}?>
 







<?/*if($arParams["USE_COMPARE"]=="Y"):?>
<?$APPLICATION->IncludeComponent(
  "bitrix:catalog.compare.list",
  "",
  Array(
    "IBLOCK_TYPE" => $arParams["IBLOCK_TYPE"],
    "IBLOCK_ID" => $arParams["IBLOCK_ID"],
    "NAME" => $arParams["COMPARE_NAME"],
    "DETAIL_URL" => $arResult["FOLDER"].$arResult["URL_TEMPLATES"]["element"],
    "COMPARE_URL" => $arResult["FOLDER"].$arResult["URL_TEMPLATES"]["compare"],
  ),
  $component
);?>




<?endif*/?>
<div class="col-xs-12 col-sm-8 col-md-8 col-lg-9">
<?$APPLICATION->IncludeComponent(
  "bitrix:catalog.section",
  "",
  Array(
    "IBLOCK_TYPE" => $arParams["IBLOCK_TYPE"],
    "IBLOCK_ID" => $arParams["IBLOCK_ID"],
    "ELEMENT_SORT_FIELD" => $arParams["ELEMENT_SORT_FIELD"],
    "ELEMENT_SORT_ORDER" => $arParams["ELEMENT_SORT_ORDER"],
 		"PROPERTY_CODE" => $arParams["LIST_PROPERTY_CODE"],
    "META_KEYWORDS" => $arParams["LIST_META_KEYWORDS"],
    "META_DESCRIPTION" => $arParams["LIST_META_DESCRIPTION"],
    "BROWSER_TITLE" => $arParams["LIST_BROWSER_TITLE"],
    "INCLUDE_SUBSECTIONS" => $arParams["INCLUDE_SUBSECTIONS"],
    "BASKET_URL" => $arParams["BASKET_URL"],
    "ACTION_VARIABLE" => $arParams["ACTION_VARIABLE"],
    "PRODUCT_ID_VARIABLE" => $arParams["PRODUCT_ID_VARIABLE"],
    "SECTION_ID_VARIABLE" => $arParams["SECTION_ID_VARIABLE"],
    "FILTER_NAME" => $arParams["FILTER_NAME"],
    "DISPLAY_PANEL" => $arParams["DISPLAY_PANEL"],
    "CACHE_TYPE" => $arParams["CACHE_TYPE"],
    "CACHE_TIME" => $arParams["CACHE_TIME"],
    "CACHE_FILTER" => $arParams["CACHE_FILTER"],
    "CACHE_GROUPS" => $arParams["CACHE_GROUPS"],
    "SET_TITLE" => $arParams["SET_TITLE"],
    "SET_STATUS_404" => $arParams["SET_STATUS_404"],
    "DISPLAY_COMPARE" => $arParams["USE_COMPARE"],
    "PAGE_ELEMENT_COUNT" => $arParams["PAGE_ELEMENT_COUNT"],
    "LINE_ELEMENT_COUNT" => $arParams["LINE_ELEMENT_COUNT"],
    "PRICE_CODE" => $arParams["PRICE_CODE"],
    "USE_PRICE_COUNT" => $arParams["USE_PRICE_COUNT"],
    "SHOW_PRICE_COUNT" => $arParams["SHOW_PRICE_COUNT"],

    "PRICE_VAT_INCLUDE" => $arParams["PRICE_VAT_INCLUDE"],

    "DISPLAY_TOP_PAGER" => $arParams["DISPLAY_TOP_PAGER"],
    "DISPLAY_BOTTOM_PAGER" => $arParams["DISPLAY_BOTTOM_PAGER"],
    "PAGER_TITLE" => $arParams["PAGER_TITLE"],
    "PAGER_SHOW_ALWAYS" => $arParams["PAGER_SHOW_ALWAYS"],
    "PAGER_TEMPLATE" => $arParams["PAGER_TEMPLATE"],
    "PAGER_DESC_NUMBERING" => $arParams["PAGER_DESC_NUMBERING"],
    "PAGER_DESC_NUMBERING_CACHE_TIME" => $arParams["PAGER_DESC_NUMBERING_CACHE_TIME"],
    "PAGER_SHOW_ALL" => $arParams["PAGER_SHOW_ALL"],

    "OFFERS_CART_PROPERTIES" => $arParams["OFFERS_CART_PROPERTIES"],
    "OFFERS_FIELD_CODE" => $arParams["LIST_OFFERS_FIELD_CODE"],
    "OFFERS_PROPERTY_CODE" => $arParams["LIST_OFFERS_PROPERTY_CODE"],
    "OFFERS_SORT_FIELD" => $arParams["OFFERS_SORT_FIELD"],
    "OFFERS_SORT_ORDER" => $arParams["OFFERS_SORT_ORDER"],
    "OFFERS_LIMIT" => $arParams["LIST_OFFERS_LIMIT"],

    "SECTION_ID" => $arResult["VARIABLES"]["SECTION_ID"],
    "SECTION_CODE" => $arResult["VARIABLES"]["SECTION_CODE"],
    "SECTION_URL" => $arResult["FOLDER"].$arResult["URL_TEMPLATES"]["section"],
    "DETAIL_URL" => $arResult["FOLDER"].$arResult["URL_TEMPLATES"]["element"],
  ),
  $component
);
?>
</div></div>
.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Andrey Kornev, 2016-05-19
@bionkin

change
on the
Thus, in $arCurSection you will have the level of the current section DEPTH_LEVEL
wrap the filter call in a condition

if($arCurSection['DEPTH_LEVEL'] >= 3):?>
  <?/*Тут вызов фильтра*/?>
<?endif;

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question