Simple redirect in new window/tab


I am using the info on this page to do a redirect to an external site from one of my menu links. It’s working great but is there any way to have the link open in a new window/tab? Do I need to add something extra to the link.php file to make this work?

Thanks in advance.

It is not possible to open a new tab/window from the backend (PHP). You need to do this in your HTML.

Instead of the redirection technique (or additional to it), you can modify your menu snippet so that it outputs the link field in place of the url field if the link field is set. And in that case you can set the target="_blank" attribute on the link so that the URL is opened in a new tab:

<li><a href="<?php e($p->link()->empty(), $p->url(), $p->link()) ?>"<?php e($p->link()->isNotEmpty(), ' target="_blank"') ?>><?php echo $p->title() ?></a></li>