0

here is the code for custom header

<div class="message global demo">
        <div class="content">
            <p>This is demo store. No orders will be fulfilled.</p>
        </div>
    </div>

i also tried in app/design but not found

which path to edit this content or any other way to edit this(RED color border content) enter image description here

3
  • Have you enabled template path hints? Jan 22, 2019 at 14:09
  • no............................ Jan 22, 2019 at 14:15
  • is there any settings in changing header in main site (admin panel) Jan 22, 2019 at 14:15

1 Answer 1

1

The content actual path is : Theme/view/frontend/templates/html/notices.phtml . directly changing content in core files is not recommended way. instead of that you can override those template file.

create layout file for override global notices

app/code/Vendor/Module/view/frontend/layout/default.xml

<?xml version="1.0"?>
<!--
/**
 * Copyright © Magento, Inc. 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>
        <referenceContainer name="after.body.start">
            <block class="Magento\Theme\Block\Html\Notices" name="global_notices" template="Vendor_Module::html/notices.phtml"/>
        </referenceContainer>
    </body>
</page>

Create a template file to override content app/code/Vendor/Module/view/frontend/templates/html/notices.phtml

<?php
/**
 * Copyright © Magento, Inc. All rights reserved.
 * See COPYING.txt for license details.
 */

// @codingStandardsIgnoreFile

?>
<?php
/**
 * @var $block \Magento\Theme\Block\Html\Notices
 */
?>
<?php if ($block->displayNoscriptNotice()): ?>
    <noscript>
        <div class="message global noscript">
            <div class="content">
                <p>
                    <strong><?= /* @escapeNotVerified */ __('JavaScript seems to be disabled in your browser.') ?></strong>
                    <span><?= /* @escapeNotVerified */ __('For the best experience on our site, be sure to turn on Javascript in your browser.') ?></span>
                </p>
            </div>
        </div>
    </noscript>
<?php endif; ?>
<?php if ($block->displayNoLocalStorageNotice()): ?>
    <div class="notice global site local_storage" style="display: none;">
        <div class="content">
            <p>
                <strong><?= /* @escapeNotVerified */ __('Local Storage seems to be disabled in your browser.') ?></strong><br />
                <?= /* @escapeNotVerified */ __('For the best experience on our site, be sure to turn on Local Storage in your browser.') ?>
            </p>
        </div>
    </div>
    <script>
require(['jquery'], function(jQuery){

        // <![CDATA[
        (function($) {
            var test = 'test';
            try {
                localStorage.setItem(test, test);
                localStorage.removeItem(test);
            } catch(e) {
                $(".notice.global.site.local_storage").show();
            }
        })(jQuery);
        // ]]>

});
</script>
<?php endif; ?>
<?php if ($block->displayDemoNotice()): ?>
    <div class="message global demo">
        <div class="content">
            <p><?= /* @escapeNotVerified */ __('This is demo store. No orders will be fulfilled.') ?></p>
        </div>
    </div>
<?php endif; ?>

Change your content whatever you want in "message global demo"

3
  • superb it's working thanks can i get your mail for future contact Jan 23, 2019 at 3:58
  • The "best" way to do this would be to override the translation CSV file instead of editing the PHTML. Jan 23, 2019 at 13:51
  • yes, you are right, if he want to change only content he can go with translation, but if we need to change styles and content he needs to override the template Jan 23, 2019 at 14:27

Your Answer

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

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