I am trying to add a template file above my footer to show a subscribe form.

In my template I have created a file app/design/frontend/<vendor>/<theme>/Magento_Theme/layout/default.xml. Here's the contents:

                <block class="Magento\Framework\View\Element\Template"
                    template="Magento_Theme::footer-subscribe.phtml" />

                <block class="Magento\Cms\Block\Block" name="ofihudui">
                  <action method="setTitle"><argument name="title" xsi:type="string">TEST</argument></action>
                  <action method="setBlockId"><argument name="block_id" xsi:type="string">test</argument></action>


I have also created the file app/design/frontend/<vendor>/<theme>/Magento_Theme/template/footer-subscribe.phtml and here's the contents:


The page will show the second block fine, but when I try to add the prefooter.subscribe block Magento gives me this error:

1 exception(s):
Exception #0 (Magento\Framework\Exception\ValidatorException): Invalid template file: 'Magento_Theme::footer-subscribe.phtml' in module: '' block's name: 'prefooter.subscribe'

Is it because I have the file in the wrong place? I'm not sure what to do here, it seems like it should work to me.

  • Have you got solution? Nov 2, 2018 at 12:29

3 Answers 3


I think u should try naming the phtml file footer_subscribe.phtml instead of footer-subscribe.phtml

  • Ahh damn. I just realised the problem... the template dir should be templates
    – Callum
    Oct 18, 2018 at 13:13
  • @Callum No if you change your template totemplates then also your problem is not solve. Oct 18, 2018 at 13:15
  • Have u tried clearing cache and reindexing after changing the template to templates
    – surbhi agr
    Oct 18, 2018 at 13:16
  • Yes there is a problem with template to templates but also one another problem as per error check my answer. Oct 18, 2018 at 13:22


<block class="Magento\Framework\View\Element\Template" name="my-custom-footersubscribe" template="Magento_Theme::html/myfooter-subscribe.phtml" />

Deploy the static-content, then Clean the cache.

php bin/magento cache:clean

php bin/magento setup:static-content:deploy -f

Important : check your phtml content, if you are calling some $block function from a module, it will not work.

In this case you create this phtml in that module then you call it in your layout like this:

<block class="{Vendor}\{Modulename}\Block\{Blockname}" name="my-custom-footersubscribe" template="Vendor_Modulename::html/myfooter-subscribe.phtml" />

As per your query i found that your problem is with below code.

<block class="Magento\Framework\View\Element\Template"
                template="Magento_Theme::footer-subscribe.phtml" />

Because, you specify block name name="prefooter.subscribe" but there is a no block found like this name.

And if you want to change the position of your block then you can use <move element="form.subscribe" destination="footer" before="-"/> like this.

Click Here for more reference.

I hope it works.

Your Answer

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

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