Redoing the site of the template. There is an "Add" button on the page. If the user is already authorized, the necessary page opens, otherwise the authorization window pops up. Here is the button code:

[[!+modx.user.id:gt=`0`:then= `<a href="[[~35]]?cat=18" class="btn" id="add">Добавить</a>` :else= `<a><button class="btn" id="add" data-toggle="modal" data-target="#logIn">Добавить</button> </a>`]] 

In one place of the site there is a group of buttons with links to pages that are defined as resources in the modex manager. Like this:

 <div class="col-md-10 col-xs-12 col-md-offset-1 menu"> [[pdoMenu? &parents=`0` &level=`1` ]] </div> 

You need to add this button to them.

I created the resource, how to redirect the user to authorization from there, if he has not yet passed it and open the necessary page, if he has passed?

    1 answer 1

    I hope I understand you correctly. pdoMenu has a default template for displaying links in a snippet:

     @INLINE <li[[+classes]]><a href="[[+link]]" [[+attributes]]>[[+menutitle]]</a>[[+wrapper]]</li> 

    To make a check, you need to connect your template in a call through a chunk and already have it checked, for example:

    chunk menuTpl:

     [[!+modx.user.id:gt=`0`:then=` <!-- Стандартный шаблон генерации ссылок в pdoMenu --> <li[[+classes]]><a href="[[+link]]" [[+attributes]]>[[+menutitle]]</a>[[+wrapper]]</li> `:else=` <!-- Тут уже вывод кнопки или любой другой вариант --> <li[[+classes]]><button class="btn" id="add" data-toggle="modal" data-target="#logIn">Добавить</button></li> ` ]] 

    And the call itself will now be like this:

     <div class="col-md-10 col-xs-12 col-md-offset-1 menu"> [[pdoMenu? &parents=`0` &level=`1` &tpl=`menuTpl` ]] </div> 

    where in tpl is our chunk created earlier.

    • And how in this menuTpl to make the test only work on this button? And the rest remained as it was? And apparently it did not differ from others, except that the inscription. In other words, it is necessary to transfer this separate button "add" stupidly from one page to pdoMenu - Vladimir Malakhov
    • Ruslan Aleev, on the basis of your answer, replaced pdoMenu and simply wrote down all the lines manually, adding your own. - Vladimir Malakhov
    • Hello, did not quite understand the problem initially. This verification condition can be written in any place, and in the template, by wrapping, for example, a call to the menu of links, and in a specific menu item. I thought that it was necessary to replace all menu items with a button by condition. - Ruslan Aleev