0

We have created a custom template to show some documents and download them. This template is located in the backend. You can access through the menu and the submenu of one of the options.

enter image description here

"Dealer Documents" is the option choose to access here. Then, if we close the menu you can see it properly: (but still without styles)

enter image description here

If we use the inspector we can see the layout appears to go to the wrong spot:

enter image description here

The red part is all the menu and the scripts. Basically, Magento's layout. And the green part is the custom template.

The layout code (app/code/ModuleVendor/ModuleName/view/adminhtml/layout/dealer_index.xml)

<?xml version="1.0" encoding="UTF-8"?>    
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"          xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
    <update handle="styles"/>
    <body>
        <container name="content" label="Root">
            <block class="ModuleVendor\ModuleName\Block\Adminhtml\Dealer\Document" name="sap.dealer.document"
                   template="ModuleVendor_ModuleName::dealer/documents.phtml"
                   />
        </container>
    </body>
</page>

And the documents.phtml

<?php if (!empty($path)){?>
    <div class="fieldset-wrapper customer-information">
        <div class="fieldset-wrapper-title">
            <span class="title"><?= __('Dealer documents') ?></span>
        </div>
        <?php
        phpContent
        ?>
        <?php condition{ ?>
            <table class="data-table">
                <thead>
                <tr>
                    <th><?= __('Name') ?></th>
                    <th><?= __('Type') ?></th>
                    <th><?= __('Size') ?></th>
                    <th><?= __('Download') ?></th>
                </tr>
                </thead>
                <tbody>
                <?php foreach ($files as $file): ?>
                    <?php $realfile = $path . $file; ?>
                    <tr>
                        <td class="col"><?=  ?></td>
                        <td class="col"><?=  ?></td>
                        <td class="col"><?=  ?></td>
                        <td class="col text-center">
                            <a target="_blank" href="" download=""><?= __('Download') ?></a>
                        </td>
                    </tr>
                <?php endforeach; ?>
                </tbody>
            </table>
        <?php } else { ?>
            <div class="message warning"><?= __("You don't have any documents.") ?></div>
        <?php } ?>
    </div>
<?php } else { ?>
    <div class="message warning"><?= __("There's no path defined in the backend.") ?></div>
<?php } ?>

What are we missing?

Your Answer

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

Browse other questions tagged or ask your own question.