我是magento 2的新手,我想在标题中添加一些简单的html,但我无法正常工作,我有一个简单的主题,覆盖了magento的空白主题,我创建了Magento_Theme文件夹,也创建了此简单的默认设置.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_configration.xsd">
<referenceContainer name="header.panel"> <!-- the name of the container you want to insert into -->
<container name="new_container" htmlClass="container_css_class" htmlTag="div">
<block class="Magento\Framework\View\Element\Template" template="Magento_Theme::template/template.phtml" name="block_name" />
</container>
</referenceContainer>
</page>
我在Magento_Theme \ template \ template.phtml文件夹中有这个简单的模板
<div class="block" style="float: right;">
<?php echo __('Custom Line'); ?>
</div>
但是magento不断触发此错误
1 exception(s):
Exception #0 (Magento\Framework\Exception\ValidatorException): Invalid
template file: 'Magento_Theme::template/template.phtml' in module: ''
block's name: 'block_name'
我使用magento 2.2.5
答案 0 :(得分:0)
我发现错误Magento_Theme ::是模板文件夹的路径,当我将我的template.phtml更改为文件夹模板并将Magento_theme :: template / template.php更改为Magento_theme :: template.php时,它起作用了>
答案 1 :(得分:0)
尝试将文件夹“模板”重命名为“模板”(添加“ s”),并使其类似
template =“ Magento_Theme :: template.phtml”