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>
sv3n
11.7k7 gold badges44 silver badges75 bronze badges
asked Aug 27, 2017 at 16:09
2
  • can you upload your code please...? Commented Aug 28, 2017 at 4:20
  • I updated my answer ... Check it. Commented 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');
 }
}
answered Aug 28, 2017 at 9:44
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 ? Commented Aug 28, 2017 at 11:44
  • Happy to help sir @KakiSami ... Happy Coding :) !! Commented Aug 29, 2017 at 4:25
  • @ManthanDave Did you ever solve the New Tab issue? Commented Aug 22, 2018 at 14:49

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.