magento - Magento 2 中小部件布局更新的自定义目标

标签 magento magento2

我需要帮助解决如何添加自定义容器作为小部件的“布局更新”..

目前,我只有 3 个基本选项可供选择(主要内容区域、主要侧边栏和附加侧边栏),但我希望能够将小部件添加到我通过各种 default.xml 文件创建的容器中.

我该如何去做呢?

谢谢, 卢克

最佳答案

在 widget.xml 中您创建了额外的区域。在目录模块下您可以看到它。

<widget id="new_products" class="Magento\Catalog\Block\Product\Widget\NewWidget" is_email_compatible="true"
        placeholder_image="Magento_Catalog::images/product_widget_new.png" ttl="86400">
    <label translate="true">Catalog New Products List</label>
    <description translate="true">List of Products that are set as New</description>
    <parameters>
        <parameter name="display_type" xsi:type="select" required="true" visible="true">
            <label translate="true">Display Type</label>
            <description translate="true">All products - recently added products, New products - products marked as new</description>
            <options>
                <option name="default" value="all_products" selected="true">
                    <label translate="true">All products</label>
                </option>
                <option name="item" value="new_products">
                    <label translate="true">New products</label>
                </option>
            </options>
        </parameter>
        <parameter name="show_pager" xsi:type="select" visible="true"
                   source_model="Magento\Config\Model\Config\Source\Yesno">
            <label translate="true">Display Page Control</label>
        </parameter>
        <parameter name="products_per_page" xsi:type="text" required="true" visible="true">
            <label translate="true">Number of Products per Page</label>
            <depends>
                <parameter name="show_pager" value="1" />
            </depends>
            <value>5</value>
        </parameter>
        <parameter name="products_count" xsi:type="text" required="true" visible="true">
            <label translate="true">Number of Products to Display</label>
            <value>10</value>
        </parameter>
        <parameter name="template" xsi:type="select" required="true" visible="true">
            <label translate="true">Template</label>
            <options>
                <option name="default" value="product/widget/new/content/new_grid.phtml" selected="true">
                    <label translate="true">New Products Grid Template</label>
                </option>
                <option name="list" value="product/widget/new/content/new_list.phtml">
                    <label translate="true">New Products List Template</label>
                </option>
                <option name="list_default"
                        value="product/widget/new/column/new_default_list.phtml">
                    <label translate="true">New Products Images and Names Template</label>
                </option>
                <option name="list_names"
                        value="product/widget/new/column/new_names_list.phtml">
                    <label translate="true">New Products Names Only Template</label>
                </option>
                <option name="list_images"
                        value="product/widget/new/column/new_images_list.phtml">
                    <label translate="true">New Products Images Only Template</label>
                </option>
            </options>
        </parameter>
        <parameter name="cache_lifetime" xsi:type="text" visible="true">
            <label translate="true">Cache Lifetime (Seconds)</label>
            <description translate="true">86400 by default, if not set. To refresh instantly, clear the Blocks HTML Output cache.</description>
        </parameter>
    </parameters>
    <containers>
        <container name="sidebar.main">
            <template name="default" value="list_default" />
            <template name="names_only" value="list_names" />
            <template name="images_only" value="list_images" />
        </container>
        <container name="content">
            <template name="grid" value="default" />
            <template name="list" value="list" />
        </container>
        <container name="sidebar.additional">
            <template name="default" value="list_default" />
            <template name="names_only" value="list_names" />
            <template name="images_only" value="list_images" />
        </container>
    </containers>
</widget>

请浏览<containers>上面的代码你就明白了。有一个容器标签

关于magento - Magento 2 中小部件布局更新的自定义目标,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38067464/

相关文章:

Magento fatal error : Call to a member function setQuote() when customer clicks “review your information” using Paypal Express Checkout

php - Magento 捆绑产品仅显示一种产品,但我在后端有两种产品

magento - 如何在magento 2中添加同名产品?

magento2 - 添加自定义过滤器以在 magento2 中进行搜索

magento - Magento 2中的Ultimo控制台错误

css - 自定义 CSS 未在某些页面上加载 - 特别是那些带有表单的页面?

jquery - 自定义添加的顶级菜单项的事件状态 [Magento topmenu]

Magento API 'Exception',消息为 'Item (Mage_Sales_Model_Order) with the same id "X“已经存在”

php - 通过 magento 中的一些 id 获取产品集合

session - Magento 2目录 ''不在存储根路径下