Question

I've created a module that includes a custom page. I can set a template block for the page title as follows:

<?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="page.main.title" template="JR2_MonthlySubscription::monthly_subscription.phtml" />
        <!--
        <referenceBlock name="page.main.title">
            <action method="setTemplate">
                <argument name="template" xsi:type="string">MYA_Subscribe::title.phtml</argument>
            </action>
        </referenceBlock>
        !-->
    </body>
</page>

This works fine, but how do I set a template for the actual page content? I've tried adding a reference block for page.wrapper to no avail. The documentation doesn't seem to mention the available page options for name.

Était-ce utile?

La solution

  1. You have to add below code into your layout XML file
<referenceContainer name="content">
    <block class="Magento\Framework\View\Element\Template" name="custom-content" template="JR2_MonthlySubscription::content.phtml" />
</referenceContainer>
  1. Add your phtml file and custom content in phtml file. app/code/JR2/MonthlySubscription/view/frontend/templates/content.phtml
<h1>Custom Content</h1>

It will show at your cusom page.

Licencié sous: CC-BY-SA avec attribution
Non affilié à magento.stackexchange
scroll top