0

I like to add a block on top order creation page, in /Vendor/Module/view/adminhtml/layout/sales_order_create_index.xml

<?xml version="1.0"?>
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" layout="admin-2columns-left" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
<head><meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
    <css src="Amanweb_Custcomment/css/custcomment.css"/>
</head>
<body>
    <referenceBlock name="content">
        <block class="Vendor\Module\Block\Adminhtml\Order\View\Custcomment" before='-' name="items"  ifconfig="custcomment/general/enable" template="order/view/custcomment.phtml" />
    </referenceBlock>
</body>
</page>

But nothing is shown.

PS: I successfully added the same block in order view page In Vendor/Module/view/adminhtml/layout/sales_order_view.xml

<?xml version="1.0"?>
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" layout="admin-2columns-left" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
<head><meta http-equiv="Content-Type" content="text/html; charset=utf-8">
    <css src="Amanweb_Custcomment/css/custcomment.css"/>
</head>
<body>
    <referenceBlock name="content">
        <block class="Vendor\Module\Block\Adminhtml\Order\View\Custcomment" before='-' name="custcomment"  ifconfig="custcomment/general/enable" template="order/view/custcomment.phtml" />
    </referenceBlock>
</body>
</page>

2 Answers 2

1

Template path in your Your sales_order_create_index.xml is not properly declared.

Try to use below sales_order_create_index.xml

<?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>
    <referenceBlock name="content">
        <block class="Vendor\Module\Block\Adminhtml\Order\View\Custcomment" before="order_content" name="mycustom_item"   template="Vendor_Module::order/view/custcomment.phtml" />
    </referenceBlock>
</body>
</page>
4
  • it works like this <?xml version="1.0"?> <page xmlns:xsi="w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd"> <body> <referenceBlock name="content"> <block class="Amanweb\Custcomment\Block\Adminhtml\Order\View\Custcomment" before="order_content" name="mycustom_item" template="order/view/custcomment.phtml" /> </referenceBlock> </body> </page> Dec 18, 2019 at 19:37
  • Adding the Vendor_Module in the template is not required, since we are in the same module Dec 18, 2019 at 19:38
  • okay. Thanks for the information. Dec 19, 2019 at 6:22
  • Adding the attribute name solved the problem! Dec 19, 2019 at 10:22
0

It works like that

<?xml version="1.0"?> <page xmlns:xsi="w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
<body> 
<referenceBlock name="content"> 
<block class="Vendor\Module\Block\Adminhtml\Order\View\Custcomment" before="order_content" name="mycustom_item" template="order/view/custcomment.phtml" /> 
</referenceBlock> 
</body> 
</page> 

Your Answer

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

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