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.
If you want get query string params in controller file,...
Create di.xml and add the below code Magemonkey/Redirect/etc/frontend/di.xml [crayon-62837a0f6c2f9328536788/] Create...
You can try below code to change local date to...
Step 1: First you need to add registration.php file in...
Step1 : Override message.js in current theme file on the...