Magento 2.2:覆盖不反映的.phtml文件

问题描述 投票:1回答:1

我是Magento2.2的新手。我试图覆盖Magneto Blank Theme.phtml文件,我已经完成了以下操作。

空白主题文件路径/Magento-Dir/vendor/magento/module-theme/view/frontend/templates/html/title.phtml

我的文件路径app / design / frontend / MyTheme / Acorn / module-theme / template / html / title.phtml

我的档案

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

// @codingStandardsIgnoreFile

/**
 * @var $block \Magento\Theme\Block\Html\Title
 */
$cssClass = $block->getCssClass() ? ' ' . $block->getCssClass() : '';
$title = '';
if (trim($block->getPageHeading())) {
    $title = '<span class="base" data-ui-id="page-title-wrapper" ' .  $block->getAddBaseAttribute() . '>'
        . $block->escapeHtml($block->getPageHeading()) . '</span>';
}
?>
<?php if ($title): ?> <h1>Test Text</h1>
<div class="page-title-wrapper<?= /* @escapeNotVerified */ $cssClass ?>">
    <h1 class="page-title"
        <?php if ($block->getId()): ?> id="<?= /* @escapeNotVerified */ $block->getId() ?>" <?php endif; ?>
        <?php if ($block->getAddBaseAttributeAria()): ?>
            aria-labelledby="<?= /* @escapeNotVerified */ $block->getAddBaseAttributeAria() ?>"
        <?php endif; ?>>
        <?= /* @escapeNotVerified */ $title ?>
    </h1>
    <?= $block->getChildHtml() ?>
</div>
<?php endif; ?>

在此之后,我运行了php bin/magento setup:static-content:deploy -f删除了pub / static / frontend文件夹,然后重新加载了我的页面。不过,它指向空白主题文件。

我跟着http://devdocs.magento.com/guides/v2.2/frontend-dev-guide/templates/template-walkthrough.html

我不是我在这里做的错误,请帮助找出错误。

php templates override magento2 magento-2.2.1
1个回答
2
投票

您的文件路径不正确。请在以下路径中覆盖此文件。

应用程序/设计/前端/ MyTheme的/橡果/ Magento_Theme /模板/ HTML / title.phtml

© www.soinside.com 2019 - 2024. All rights reserved.