首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >添加块magento2

添加块magento2
EN

Stack Overflow用户
提问于 2019-07-31 14:36:57
回答 1查看 119关注 0票数 0

如何在magento中的标准magento Luma主题中向左侧边栏添加带有图片的块,如图中所示

我试过这种方法

app/design/frontend/TestTheme/Theme/Magento_Catalog/layout/catalog_product_view.xml

代码语言:javascript
复制
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" layout="1column" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
    <body>
        <referenceBlock name="catalog.compare.sidebar">
            <action method="setPageTitle">
                    <argument name="logo_file" xsi:type="string">images/logo.svg</argument>
                    <argument name="logo_img_width" xsi:type="number">200</argument>
                    <argument name="logo_img_height" xsi:type="number">200</argument>
            </action>
        </referenceBlock>
    </body>
</page>

但这不管用

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2019-07-31 16:19:39

代码语言:javascript
复制
Magento_Theme
---layout
-----default.xml
---youtemps
-----img.phtml

mb不是最好的实现,但是这个方法会给你带来文本,不幸的是,没有演示我无法告诉你如何显示。

我希望你能被告知如何改进这个方法,或者尝试根据我的代码完成我的任务。

代码语言:javascript
复制
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
    <body>
        <referenceContainer name="sidebar.additional">
            <container name="sidebar.img.container" htmlClass="pseudo-container" htmlTag="div">
                <block class="Magento\Framework\View\Element\Template" name="testtest.sidebar.sell" as="sell_lable" template="Magento_Theme::youtemps/img.phtml" before="-"/>
            </container>
        </referenceContainer>
    </body>
</page>

更新,在phtml文件中添加以下代码

代码语言:javascript
复制
<h2 style="margin: 0">hot price</h2>
<img src="<?php echo $this->getViewFileUrl('images/sell-sidebar.jpg'); ?>" style="margin-bottom: 10px" alt="" />

在您的Magento_Theme文件夹中添加图像文件夹并放入您的图像文件夹中,接下来插入到getViewFileUrl('images/sell-sidebar.jpg');的路径相对为Magento_Theme

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/57293298

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档