我想了解如何将自定义容器添加为窗口小部件的“布局更新”。
目前,我只有3个基本选项可供选择(主要内容区域,Siderbar Main和Sidebar附加),但我希望能够将小部件添加到我通过各种default.xml文件创建的容器中
我将如何做到这一点?
谢谢, 路加
答案 0 :(得分:2)
在widget.xml中创建其他area.Under目录模块,您可以看到。
<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>
标记。有一个容器标记