2

I try to change the theme for a product to the default Magento Blank theme. But I get this error:

Exception #0 (Magento\Framework\Exception\ValidatorException): Invalid template file: 'Company_Base::header/mobile/icons/search.phtml' in module: '' block's name: 'mobile-search'

The file Company_Base::header/mobile/icons/search.phtml is from my custom theme. It is defined here app/design/frontend/company/fresh/Magento_Theme/layout/default.xml.

Why does it even try to load a template from my custom theme if I want to load the Magento Blank theme?

Why do I get this error?

I already tried to recompile everything and clear cache, does not help.

Tested in Magento 2.4.2


If I change the theme globally to Magento Blank then I also get errors. But they dissapear after I disable all third party modules and enable them one by one compiling at each step.

1 Answer 1

0

Looks like you declear block 'mobile-search' with template Company_Base::header/mobile/icons/search.phtml in your module, so it will load for all themes, but the problem here is the file does not exist in app/code/Company/Base/view/frontend/templates/header/mobile/icons/search.phtml.

7
  • No, the only occurence of search.phtml is in the theme. I searched the whole codebase for search.phtml and this is the only thing it found, besides some other search.phtml from the core
    – Black
    Commented Oct 13, 2022 at 15:42
  • I still would like to check if you declare block mobile-search with template Company_Base::header/mobile/icons/search.phtml in your module or not (in case you declare block in layout XML in module and put the phtml file in your custom theme). Could you please run grep -r mobile-search app/code to get results?
    – Tu Van
    Commented Oct 13, 2022 at 18:40
  • If you don't get any results with the command above, let's remove var/view_preprocessed/pub/static/frontend/ and pub/static/frontend folders before running the deploy static content command. The clear cache and go to the frontend page to check the result.
    – Tu Van
    Commented Oct 14, 2022 at 3:01
  • If the issue still persists, try to temporary remove <your custom theme>/Company_Base/templates/header/mobile/icons/search.phtml and related layout xml file. Then remove var/view_preprocessed/pub/static/frontend/ and pub/static/frontend folders before running the deploy static content command. Then clear cache and go to the frontend page to check the result.
    – Tu Van
    Commented Oct 14, 2022 at 3:29
  • 1. It is defined here app/design/frontend/hausfux/fresh/Magento_Theme/layout/default.xml
    – Black
    Commented Oct 14, 2022 at 6:12

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.