Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to make a target_blank Menu link in EasyAdminBundle?

In EasyAdmin dashboard, i added a 'View website' link in the left menu:

enter image description here

But i would like it to open a new browser window on click. And I am wondering how to add a target="_blank" attribute to it (or any other solution to get this result).

For now i have this code in App\Controller\Admin\DashboardController.php:

public function configureMenuItems(): iterable
{
    yield MenuItem::linkToDashboard('Dashboard', 'fas fa-tachometer-alt');
    yield MenuItem::linkToUrl('View website', 'fas fa-eye', '/')
        ->setPermission('ROLE_ADMIN');
    // ...
}

Thank you!

like image 678
Edouard Avatar asked Nov 30 '25 03:11

Edouard


1 Answers

 yield MenuItem::linkToUrl('Homepage', 'fa fa-home', $this>generateUrl('homepage'))
        ->setLinkTarget(
            '_blanc'
        );
like image 163
KrOvean Avatar answered Dec 02 '25 18:12

KrOvean