如何在此图像中添加块到magento 2 luma标头? 我正在使用M2.2并且app / design / frontend / magento目录是空的(我看到引用了很多)。
最新回答
- 2019-12-51 #
- 2019-12-52 #
在以下路径的default.xml文件中添加此代码
/app/code/design/frontend/MyCompany/MyTheme/Magento_Search/layout/default.xml
<?xml version="1.0"?> <page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd"> <body> <referenceContainer name="header-wrapper"> <block class="Magento\Framework\View\Element\Template" name="customFile" template="Magento_Search::customFile.phtml" /> </referenceContainer> </body>
现在,在下面的路径中创建模板文件
/app/code/design/frontend/MyCompany/MyTheme/Magento_Search/templates/customFile.phtml
<div class="block" style="float: right;margin-bottom: 0.5%;margin-top: 0.5%;"> <?php echo __('This is Custom Text File'); ?> </div>
希望,这对你有所帮助。
在
top.search
之后添加以下代码 referenceContainer:Note: 需要更改块id
topPromo
使用您的块ID并需要一些CSS进行定位。