B
B
butize2021-04-09 08:30:06
1C-Bitrix
butize, 2021-04-09 08:30:06

How to display the total number of news available on the site in the header on the site on Bitrix?

Good afternoon! I have a list of news on my site (news.list). I need to display the total number of news in the menu in the header. It's just that there should be a figure above the News item with the total number of news on the site.
I was sitting yesterday, but I still didn’t figure out how to get this amount and how to pass it to another component ... Help, please
Thank you

Answer the question

In order to leave comments, you need to log in

1 answer(s)
Y
Yaroslav Alexandrov, 2021-04-09
@butize

1) Add the result_modifier.php file to the menu
https://dev.1c-bitrix.ru/learning/course/index.php...
https://dev.1c-bitrix.ru/learning/course/index.php ...
https://dev.1c-bitrix.ru/learning/course/index.php...
2) get the number of elements via GetList
https://dev.1c-bitrix.ru/api_help/iblock/classes/ c...
Get only the quantity at once, the $arGroupBy parameter in the GetList() call. In the documentation "If you specify an empty array as arGroupBy, the method will return the number of CNT elements by the filter"
3) Add your key with the number of news to the resulting array

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question