【问题标题】:Why is my .phtml file override not being reflected? [closed]为什么我的 .phtml 文件覆盖没有被反映? [关闭]
【发布时间】:2017-12-13 07:33:29
【问题描述】:

我是 Magento 2.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 overriding magento2 magento2.2


    【解决方案1】:

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

    app/design/frontend/MyTheme/Acorn/Magento_Theme/template/html/title.phtml
    

    【讨论】:

      猜你喜欢
      • 2023-01-03
      • 2015-07-31
      • 2020-05-12
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-02-21
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多