MODX creates wrong menu url from title

Hello.

I have a problem with a mobile page on Modx.

On computer menu links work OK, but when I switch to mobile page, MODX creates custom links from titles of subpage.

For example if some page is on 3rd level, MODX will create link page. com/3rdlevel and not for example page. com/2ndlevel/3rdlevel.

Also if title is About Site, and correct url is page .com/about, MODX will create link page .com/aboutpage (and than i get error 404).

Code for my computer and mobile page (i have a dropdown menu on mobile page):

 <nav role="navigation">
     
[[!pdoMenu?
    &parents=`0`
    &level=`2`
    &tplOuter=`@INLINE <ul id="mainNav">[[+wrapper]]</ul>`
    &tpl=`@INLINE <li [[+classes]]><a href="[[+link]]">[[+menutitle]]</a></li>`
    &tplParentRow=`@INLINE <li><a href="[[+link]]">[[+menutitle]]</a>[[+wrapper]]</li>`
    &tplInner=`@INLINE <ul>[[+wrapper]]</ul>`
    &tplInnerRow=`@INLINE <li><a href="[[+link]]">[[+menutitle]]</a></li>`
    &where=`{"template:!=":"3"}`
    &scheme=`full`
    

]]
<select id="mobileNav">
    [[!pdoMenu?
    &parents=`0`
    &level=`2`
    &tplOuter=`@INLINE <option>[[+wrapper]]</option>`
    &tpl=`@INLINE <option [[+classes]]><a href="[[+link]]">[[+menutitle]]</a></option>`
    &tplParentRow=`@INLINE <option><a href="[[+link]]">[[+menutitle]]</a>[[+wrapper]]</option>`
    &tplInner=`@INLINE <option>[[+wrapper]]</option>`
    &tplInnerRow=`@INLINE <option><a href="[[+link]]">[[+menutitle]]</a></option>`
    &hereClass=`nav-item active`
    &where=`{"template:!=":"3"}`
]]
</select>

I’m not sure I completely understand your problem. Are you saying that the first call to pdoMenu works correctly, but the links in the second call to pdoMenu are wrong?

Maybe try explicitly setting the &scheme property for the second call as well.

It’s unlikely but it could be a problem with using inline templates. You could try replacing the placeholders in the inline templates with curly braces ({{+..}}). Also, there is no need to call pdoMenu uncached.

[[pdoMenu?
    &parents=`0`
    &level=`2`
    &tplOuter=`@INLINE <option>{{+wrapper}}</option>`
    &tpl=`@INLINE <option {{+classes}}><a href="{{+link}}">{{+menutitle}}</a></option>`
    &tplParentRow=`@INLINE <option><a href="{{+link}}">{{+menutitle}}</a>{{+wrapper}}</option>`
    &tplInner=`@INLINE <option>{{+wrapper}}</option>`
    &tplInnerRow=`@INLINE <option><a href="{{+link}}">{{+menutitle}}</a></option>`
    &hereClass=`nav-item active`
    &where=`{"template:!=":"3"}`
]]

This should be controlled by the system setting use_alias_path for the whole page.

First menu looks like this:
image

Second menu looks like this:
image

I don’t know how links in second menu are generated (it looks like it creates them from TITLE of the page).
image

I think pdoMenu uses the MODX function makeUrl to create the links (like all other extras).
And this function uses the value of the “Resource Alias” to create the Url.

Maybe check the columns alias and uri of the database table modx_site_content to see if these values are correct.

The problem with wrong links is (i think) in id=“mobileNav”.

But when i delete mobileNav from select, now the is no URL, only text in menu.

I think there is no problem with the urls.

You are probably just producing incorrect html. I don’t think you can use other tags inside <option> and you can’t nest <option>-tags inside each other.

If you really have to use a <select>, then maybe use a data attribute for the link in the <option> tag and add some javascript code to load the page when the option is selected.