2

Issue

Exception #0 (Magento\Framework\Exception\ValidatorException): Invalid template file: 'TT::calculator.phtml' in module: 'Magento_Catalog' block's name: 'calculator.tab'

Layout Location:

app/code/TT/Calculator/view/frontend/layout/catalog_product_view.xml

<?xml version="1.0"?>
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
<body>
 <referenceBlock name="product.info.details">
 <block class="Magento\Catalog\Block\Product\View" name="calculator.tab" template="TT::calculator.phtml" group="detailed_info">
 <arguments>
 <argument translate="true" name="title" xsi:type="string">Calculator</argument>
 </arguments>
 </block>
 </referenceBlock>
</body>
</page>

Template Location:

app/code/TT/Calculator/view/frontend/templates/calculator.phtml

Questions

  1. I've seen some solutions where the *.phtml file is saved in app/design but I'm trying to get this to work in app/code. What have I missed?
  2. Also, does this "extend" catalog_product_view.xml or replace it?
asked Nov 27, 2017 at 15:55
2
  • You have to change to TT_Calculator::calculator.phtml. Commented Nov 27, 2017 at 15:56
  • I typo'd after fixing, making me think it didn't work. Thanks all! Commented Nov 27, 2017 at 16:37

3 Answers 3

5

1.You have to change the code to TT_Calculator::calculator.phtml:

<?xml version="1.0"?>
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
<body>
 <referenceBlock name="product.info.details">
 <block class="Magento\Catalog\Block\Product\View" name="calculator.tab" template="TT_Calculator::calculator.phtml" group="detailed_info">
 <arguments>
 <argument translate="true" name="title" xsi:type="string">Calculator</argument>
 </arguments>
 </block>
 </referenceBlock>
</body>
</page>

2.Magento will check all the layout (XML file) in all the modules and merge them, not extend.

answered Nov 27, 2017 at 15:59
0
5

Your template file location should be TT_Calculator::calculator.phtml

<block class="Magento\Catalog\Block\Product\View" name="calculator.tab" template="TT_Calculator::calculator.phtml" group="detailed_info">
 <arguments>
 <argument translate="true" name="title" xsi:type="string">Calculator</argument>
 </arguments>
 </block>
answered Nov 27, 2017 at 15:57
0

I have resolved this issue now. The problem was the allow symlink of the system config:

php bin/magento config:set dev/template/allow_symlink 1 --lock-env

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.