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?
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>
-
can you upload your code please...?Rohan Hapani– Rohan Hapani2017年08月28日 04:20:26 +00:00Commented Aug 28, 2017 at 4:20
-
I updated my answer ... Check it.Rohan Hapani– Rohan Hapani2017年08月28日 09:53:57 +00:00Commented Aug 28, 2017 at 9:53
1 Answer 1
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');
}
}
-
+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 ?Manthan Dave– Manthan Dave2017年08月28日 11:44:40 +00:00Commented Aug 28, 2017 at 11:44
-
Happy to help sir @KakiSami ... Happy Coding :) !!Rohan Hapani– Rohan Hapani2017年08月29日 04:25:47 +00:00Commented Aug 29, 2017 at 4:25
-
@ManthanDave Did you ever solve the New Tab issue?Craig– Craig2018年08月22日 14:49:13 +00:00Commented Aug 22, 2018 at 14:49