S
S
SpeakLive912018-11-13 23:16:06
1C-Bitrix
SpeakLive91, 2018-11-13 23:16:06

How to hide empty sections from infoblock in Bitrix menu.section?

Goodnight. The task is as follows: you need to remove all empty sections from menu_ext (import of the bitrix:menu.sections component).
Component code:
https://pastebin.com/bXctZxLj
I already tried to add lines there

if(0 == $arSection["ELEMENT_CNT"])
       {
       //var_dump($arSection["ID"]);
       unset($arSection["ID"]);
       }

But since I am writing here, it means that this code does not work. Well, at least it can now display the IDs of empty partitions, if it is of course necessary.
The question now is: what is missing or did I write something wrong?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
S
Sergey, 2018-11-14
@SpeakLive91

Well, as an example, just do not add to the array

while($arSection = $rsSections->GetNext())
        {
           if($arSection["ELEMENT_CNT"])
           {
         
   $arResult["SECTIONS"][] = array(
                "ID" => $arSection["ID"],
                "DEPTH_LEVEL" => $arSection["DEPTH_LEVEL"],
                "~NAME" => $arSection["~NAME"],
                "~SECTION_PAGE_URL" => $arSection["~SECTION_PAGE_URL"],
            );
            $arResult["ELEMENT_LINKS"][$arSection["ID"]] = array();
  
         
           }
           
        }

A
Alexey, 2018-11-14
@AlexeyCaTHaR

You can’t just take and edit something in the component right away. get the list of sections into an array and work with it.
Well, you may well not use the component, but write your own selection on CIBlockSection::GetList()

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question