Z
Z
z_u_q2018-06-21 22:30:08
1C-Bitrix
z_u_q, 2018-06-21 22:30:08

How to make an anchor menu in Bitrix?

When creating a regular menu, sections are created, but I don’t need them, I have a one-pager. Accordingly the question. How to make an anchor menu in Bitrix so that it can be edited from the admin panel? Who faced, can you explain?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
I
Ivan Ivanov, 2018-06-22
@z_u_q

just like a regular menu. Only for example instead of /catalog/ write #block1. Anchor #block1 will be added to the href of the created menu. And set id = "block1" for the required block.

A
Andrey Savrasov, 2018-06-22
@alcorn

To do this, the page needs blocks with an id to which scrolling will occur.
Example: After adding, turn on the edit mode, hover over the menu "Edit menu items" In the "link" field, enter #test1 If you need smooth scrolling, then this is already JavaScript.

$(document).ready(function(){
    $('.go_to').click( function(){ // ловим клик по ссылке с классом go_to
  var scroll_el = $(this).attr('href'); // возьмем содержимое атрибута href, должен быть селектором, т.е. например начинаться с # или .
        if ($(scroll_el).length != 0) { // проверим существование элемента чтобы избежать ошибки
      $('html, body').animate({ scrollTop: $(scroll_el).offset().top }, 500); // анимируем скроолинг к элементу scroll_el
        }
      return false; // выключаем стандартное действие
    });
});

In order for js to work, you need to add class="go_to" to the link tags in the menu component

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question