0

i am adding a phtml page on shipping page but its also adding on payment page

checkout_index_index.xml.

<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../../../lib/internal/Magento/Framework/View/Layout/etc/page_configuration.xsd" layout="2columns-left">
    <body>
        <referenceContainer name="content">
            <block class="SY\Avatar\Block\Customer\Account\Avatar" name="customer_account_avatar" as="customer.account.avatar" before="customer_account_dashboard_info" template="customer/account/Otp.phtml" />
            <action method="setPosition">
                  <argument name="position" xsi:type="string">checkout-content-top</argument>
              </action>
              <item name="sortOrder" xsi:type="string">1</item>
        </referenceContainer>
    </body>
</page>

but its on also payment page. what should i do ? anyone can help me

1

In your case you need to add the action inside the block like this:

<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="SY\Avatar\Block\Customer\Account\Avatar" name="customer_account_avatar" as="customer.account.avatar" before="customer_account_dashboard_info" template="customer/account/Otp.phtml">
              <action method="setPosition">
                  <argument name="position" xsi:type="string">checkout-content-top</argument>
              </action>
              <item name="sortOrder" xsi:type="string">1</item>
            </block>
        </referenceContainer>
    </body>
</page>

To add a simplest phtml file you could use this xml:

<referenceContainer name="content">
        <container name="block.container" htmlTag="div" htmlId="test.id.container" htmlClass="block-home-container" before="">
            <block class="Magento\Framework\View\Element\Template" name="block.banner" as="block.custom.cms" template="Magento_Theme::block.phtml" after="-" />
        </container>
</referenceContainer>

The action is instanciate inside the referenceBlock and block not on referenceContainer.

  • its not working for me .. i fallowed your instruction – Sarvesh Tiwari Apr 10 '17 at 14:15
  • still otp.phtml is showing on shipping and payment page – Sarvesh Tiwari Apr 10 '17 at 14:20
  • @ErSarveshVTiwari try to remove the 2columns-left like I did now on my answer. – Rafael Corrêa Gomes Apr 10 '17 at 14:27
  • its still not working ... – Sarvesh Tiwari Apr 10 '17 at 14:30
  • Try to change the class of your block, to compare with your custom class is right. Use this class Magento\Framework\View\Element\Template – Rafael Corrêa Gomes Apr 10 '17 at 14:33

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.