Wayfinder: open menu links a new window with "_blank" attribute


I’m new to MODx and I am having some issues with Wayfinder.

I have a sidebar with a menu that I am recalling using it.

I have this Chunk:

<!-- <h3>[[*longtitle:default=`[[*pagetitle]]`]]</h3> -->
    <div class="row-fluid">
        <div class="col-md-9">
        <div class="col-md-3 is-sidebar">
            <h2>Sidebar Menu</h2>
            [[!Wayfinder? &startId=`4` &level=`0`]]


What I would like to do is to add a “_blank” attribute to every menu entry so they will open in a new window.

How can I do it?

Thanks a lot in advance

Welcome to the Community! :blush:

Each list item of your Wayfinder call is defined in the rowTpl chunk, so you need to define this in your call to override the default:


Then create a chunk with the same name, in this case menuItem and add in the target attribute to the link:

<li[[+wf.id]][[+wf.classes]]><a href="[[+wf.link]]" title="[[+wf.title]]" [[+wf.attributes]] target="_blank">[[+wf.linktext]]</a>[[+wf.wrapper]]</li>

You can find more details on how to customize Wayfinder in the Docs.

On each resource you can enter the “Link Attributes” field - if you enter target="blank" in there, that will automatically make its way into the Wayfinder-generated menu ([[+wf.attributes]] in the chunk @vibedesign posted).

1 Like