0

app/design/frontend/Vendor/Customtheme/Magento_Theme/layout/default.xml

<?xml version="1.0"?>
<!--
/**
 * Copyright © 2016 Magento. All rights reserved.
 * See COPYING.txt for license details.
 */
-->
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
    <body>
        <referenceBlock name="register-link" remove="true" />
        <referenceBlock name="authorization-link" remove="true" />
        <referenceBlock name="wish-list-link" remove="true" />
        <referenceBlock name="my-account-link" remove="true" />
        <referenceBlock name="top.links" remove="true" />
        <referenceBlock name="header.panel.wrapper" remove="true" />
        <referenceBlock name="header.container" remove="true" />

        <referenceContainer name="page.wrapper">
            <container name="custom.header" htmlClass="headerSection" htmlTag="div" before="main.content">
                <block class="Magento\Framework\View\Element\Template" name="navigation.sections" before="-" template="Magento_Theme::html/customheader.phtml">

                </block>
            </container>
        </referenceContainer>
    </body>
</page>

app/design/frontend/Vendor/Customtheme/Magento_Theme/templates/html/customheader.phtml

<h1>Custom Header Content here</h1>

It's giving me this error

Exception #0 (Magento\Framework\Exception\ValidatorException): Invalid template file: 'Magento_Theme::html/customheader.phtml' in module: '' block's name: 'navigation.sections'

2
  • Your code seems correct.. just try to clear cache and deploy content if in production mode..
    – Pawan
    Commented Nov 21, 2021 at 13:16
  • I tried both commands "clear cache" and "static content deploy." Commented Nov 21, 2021 at 13:28

1 Answer 1

0

Try this code :

<referenceBlock name="navigation.sections">
    <action method="setTemplate">
        <argument name="template" xsi:type="string">Magento_Theme::html/customheader.phtml</argument>
    </action>
</referenceBlock>

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.