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?
2
  • You have to change to TT_Calculator::calculator.phtml.
    – Nero Phung
    Commented Nov 27, 2017 at 15:56
  • I typo'd after fixing, making me think it didn't work. Thanks all!
    – Craig
    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.

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>
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

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.