0

I wanted to put some external links on my magento 2 admin page so users could easily acess intranet, mail and google spreadsheets.

I managed to get links in to the backend but as sooon as they were external the backend crashed and I couldnt login.

Is this a security measure? Can I work around it?


my links area

Its from http://alanstorm.com/magento_2_admin_menu_items/ When I try to change action into a link it breaks.


         parent="Pulsestorm_MenuTutorial::top_level_example"
         action="cms/page/index"
        />                            
    <!-- END:   new node -->                
</menu>

2
  • can you upload your code please...? Aug 28, 2017 at 4:20
  • I updated my answer ... Check it. Aug 28, 2017 at 9:53

1 Answer 1

2

You can not use external link direct in menu.xml file.

Use the following way to redirect external link :

menu.xml :

<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../Magento/Backend/etc/menu.xsd">
    <menu>
        <add id="Abc_Blog::view" title="Abc Blog" module="Abc_Blog" sortOrder="11" action="your controller path" resource="Abc_Blog::view"/>
    </menu>
</config>

Redirect.php (Controller File) :

<?php
namespace Abc\Blog\Controller\Adminhtml\Grid;

use Magento\Backend\App\Action\Context;
use Magento\Framework\App\Response\RedirectInterface;
use Magento\Backend\App\Action;
class Redirect extends Action
{
    protected $_redirect;  
    public function __construct(
        Context $context,
        RedirectInterface $redirect
    ) {
        parent::__construct($context);
        $this->_redirect = $redirect;
    }


    public function execute()
    {
        return $this->_redirect('https://google.com');
    }
}
3
  • +1 from my side , just quick question what if i need to open it in new tab ? when i click on admin menu external link needs to open in new tab ? Aug 28, 2017 at 11:44
  • Happy to help sir @KakiSami ... Happy Coding :) !! Aug 29, 2017 at 4:25
  • @ManthanDave Did you ever solve the New Tab issue?
    – Craig
    Aug 22, 2018 at 14:49

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.