I am working on magento 2.1 extension in which i have to show popup on all pages. I have write a code for popup which is showing on only one page but i want to apply that code on all pages.

  • add your layout xml file code for more information . – Suresh Chikani Oct 10 '16 at 12:32

go to your module file add this code in your default.xml you file path will be Vendor/Modulename/view/frontend/layout/default.xml

<referenceContainer name="after.body.start">
            <block class="Magento\Framework\View\Element\Template" name="afterbody"  template="Vendor_Modulename::youfile.phtml"/>
  • Can I show a template to all pages without using a module or does it only work with a module? – Black Jun 1 '18 at 10:14
  • @Black yes you can use theme default.xml – Qaisar Satti Jun 1 '18 at 10:28
  • there is no theme called "default.xml". Oh I noticed that the question is about Magento 2, I still use 1.8 though. – Black Jun 1 '18 at 10:32
  • @Black i am asking you about create layout file in your theme – Qaisar Satti Jun 1 '18 at 10:33
  • I already created a custom layout file called alert.xml. Maybe if you have time you can take a look here, I just created a question – Black Jun 1 '18 at 10:36

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.