1

I want to show some new custom block in magento admin dashboard as well as want to remove some existing unwanted blocks?

How can i do this?

  • Which block you want to remove from dashboard ? – Kishan Savaliya Dec 10 '19 at 8:59
  • @KishanSavaliya i want to remove entire existing blocks and want to add my own custom block which have some custom tables reporting. – Mujahidh Dec 10 '19 at 9:00
  • Means you want to remove existing blocks which is available on dashboard and you need to add all custom blocks ? – Kishan Savaliya Dec 10 '19 at 9:01
  • yes exactly that's what i want? – Mujahidh Dec 10 '19 at 9:07
  • 1
    Sure thank you. I will check and update your. – Mujahidh Dec 10 '19 at 9:12
5

How to add new custom block on admin dashboard Magento 2?

You can add this file in your custom module here

app/code/Vendor/Module/view/adminhtml/layout/adminhtml_dashboard_index.xml

Content for this file is..

<?xml version="1.0"?>
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
    <body>
        <referenceContainer name="content">
            <block class="Magento\Framework\View\Element\Template" name="custom_block" template="Vendor_Module::test.phtml" before="-" />
        </referenceContainer>
    </body>
</page>

Now you need to create one phtml file here at this location

app/code/Vendor/Module/view/adminhtml/templates/test.phtml

Content for this file is..

<?php echo "Custom Block"; ?>

How to remove default Magento blocks from dashboard ?

You need to add below lines in your XML file adminhtml_dashboard_index.xml inside <body> tags.

<referenceBlock name="dashboard" remove="true" />
<referenceBlock name="analytics_service_external_link" remove="true" />

Output :

enter image description here

Hope this will help you!

  • 1
    Thank you, its worked for me, I will build my requirement on that. – Mujahidh Dec 10 '19 at 9:41
  • 1
    Great! Happy Coding. +1 for acceptance! :) – Kishan Savaliya Dec 10 '19 at 9:41

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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