B
B
BlaYzErR2020-04-09 12:02:33
Bitrix24
BlaYzErR, 2020-04-09 12:02:33

Where is this counter in the code (boxed version)?

I created my own top menu and the question arose how to connect this counter?5e8ee4a0ca834524969411.png

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
Andrey Nikolaev, 2020-04-13
@BlaYzErR

Before you start: Yes, you can display a counter, but if you want to update the data via a push server, you need to slightly modify the menu template.
And by counters, I understand the standard mechanism using the API: CUserCounter (b_user_counter table)
To display a number, you need to do the following: when describing the menu (.left.menu.php), you need to add the counter_num parameter to the 3rd parameter of the item.

Array(
  'Test menu',
  "/test", 
  Array(), 
  Array(
    'counter_num' => 7,
  ), 
  "" 
),

In this case, 7 is the number that will be displayed next to the number.
The counter itself can be filled with data from anywhere.
However, if you want to add a counter updated via the push server, then you need to add one more parameter counter_id (this is the identifier of the standard Bitrix counter):
Array(
  'Test menu',
  "/test", 
  Array(), 
  Array(
    "counter_id" => "test-counter-menu",
    'counter_num' => 7,
  ), 
  "" 
),

Further, in the menu component template (/bitrix/templates/bitrix24/components/bitrix/menu/top_horizontal/template.php)
$items[] = $newItem;
add before the code:
if ( isset($item["PARAMS"]["counter_id"]) )
{
  $newItem['COUNTER_ID'] = $item["PARAMS"]["counter_id"];
}

Now when you update the counter, it will be automatically updated for users.

D
Dimonchik, 2020-04-12
@dimonchik2013

ask Bitrix

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question