I have two phtml files, I want to use one for just the heading title and content. then the second phtml file I want to use it to call a table with a simple form submission. is this possible, if anyone could show me any example or guide will be helpful.

I have tried to use this but the content shows correctly but the root is showing after my footer https://magento.stackexchange.com/a/206329/96152


Please use the following code.

<?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">
    <referenceContainer name="content">
      <block class="Vendor\Module\Block\Header" name="header.content" template="header_page.phtml" />
    <referenceContainer name="root">
      <block before="footer-container" class="Vendor\Module\Block\Footer" name="custom_footer" template="custom_footer.phtml" />
  • when i put this the root is showing after my footer, i have used this code which i did mention on my question
    – Tj1997
    May 18 at 7:14

You can add a block to a phtml file and assign a specific template. E.g.

<?= $block->getLayout->createBlock('Magento\Framework\View\Element\Template')->setTemplate('Custom_Module::form.phtml') ?>

In this example, a generic block class is specified for createBlock. This block class can render a phtml file that doesn't have any specific required arguments.

I am also referencing a template file from a hypothetical custom extension. It could point any existing module/template path.

  • i am trying to split a phtml in to two, i don't know how this will work please can you tell me how this work
    – Tj1997
    May 18 at 7:15

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.