It's only on the homepage

enter image description here

When I go to another page it doesn't show anything and gives an error

enter image description here

Here are my files

enter image description here

Here is my modal_popup.js file:

enter image description here

And here is my requirejs-config.js file :

enter image description here

I put it in magento_Cms, this is the path where I put www/html/magento245/app/design/frontend/themeCustom/ firefox/Magento_Cms

I'm new to magento 2, please help me to fix it

1 Answer 1


I guess you declare your phtml file in <your theme dir>/Magento_Cms/layout/cms_index_index.xml, so your phtml file (which contains popup HTML div) is only available on the homepage.

In order to add your phtml file to all pages, you should declare it in default.xml in your module or your theme:

  • <your theme dir>/Magento_Theme/layout/default.xml
  • <your module dir>/view/frontend/layout/default.xml
  • thanks it's work !!
    – tanh
    Feb 8 at 7:57
  • You're welcome!
    – Tu Van
    Feb 8 at 10:50

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.