Let’s initiate a discussion!!
If you want to open a new window when you click on the button & use the empty layout in it then you have to follow the below steps.
Step 1: Place a new button in the admin and you have to make the on-click as per the below code.
1 2 3 4 5 6 7 8 9 10 |
$this->setChild( 'add_print_button', $this->getLayout()->createBlock('Magento\Backend\Block\Widget\Button')->setData( [ 'label' => __('Print Registry'), 'onclick' => "window.open('".$printUrl."','_blank', 'toolbar=yes,scrollbars=yes,resizable=yes')", 'class' => 'task action-primary registry-print', ] ) ); |
Step 2: Now in your controller you have to copy-paste the below code in the execute method to display your content in the empty layout.
1 2 3 4 5 6 7 8 9 10 11 |
/** @var \Magento\Backend\Model\View\Result\Page $resultPage */ $resultPage = $this->resultFactory->create(ResultFactory::TYPE_PAGE); $registryId = $this->getRequest()->getParam('registry_id'); $registry = $this->registryFactory->create()->load($registryId); $items = $this->getPrintItems($registryId); $resultPage->addHandle('admin-empty'); $this->_addContent($resultPage->getLayout()->createBlock('\Mirasvit\Giftr\Block\Mail\Printitems')->setRegistry($registry)->setPrintItems($items)); return $resultPage; |
That’s it. Now I can see content in the empty layout page in the Magento admin side by clicking the button.
Note: This code is designed as per our requirement. You can modify it as per your requirements.
[crayon-642166e801a69695825863/] Using above fucntion Images can be imported directly from...
Override view block using di.xml and add the below code...
You can check a list of called layout XML for...
Follow the below steps to install and set up PWA...
If you want to remove all leading zero's from order,...
Let our Magento expert connect to discuss your requirement.
We offer Magento
certified developers.
Our Magento clientele
is 500+.
We sign NDA for the
security of your projects.
We’ve performed 100+
Magento migration projects.
Free quotation
on your project.
Three months warranty on
code developed by us.