imi / m2-breadcrumbs
Requires
- magento/framework: ^102.0.0|^103.0.0
- magento/module-customer: ^102.0.0|^103.0.0
- magento/module-store: ^101.0.0
- magento/module-theme: ^101.0.0
This package is auto-updated.
Last update: 2024-09-21 18:15:59 UTC
README
Magento 2(与Magento 1相同)有许多页面缺少面包屑。
其中一些可能不需要它们,但我想其他一些可能需要。
特别是对于客户账户页面。
拥有面包屑将提高客户体验并使导航更容易。
这是基于已不再维护的 https://github.com/tzyganu/m2-breadcrumbs
安装
composer require imi/m2-breadcrumbs
您可以在 etc/frontend/breadcrumbs.xml
中找到受支持的页面列表。
如果您不希望特定页面有面包屑,则可以从 Stores->Configuration->Easylife Breadcrumbs
管理页面。
扩展
如果您有其他认为需要面包屑的页面,请创建一个依赖于此模块的模块,并添加一个文件 etc/frontedn/breadcrumbs.xml
,该文件由相同的 xsd 文件 Easylife/Breadcrumbs/etc/frontend/breadcrumbs_file.xsd
验证,您可以在其中列出您的页面。
您可以通过在配置文件中添加以下内容来添加新页面
<page id="page_layout_handle" group="group_code"><!-- available groups are listed also in breadcrumbs.xml -->
<label>Store configuration label here</label>
<methods>
<method name="methodNameHere" sort="10" class="Class\Name\Here" /><!-- this will call the method Class\Name\Here::methodNameHere on the event controller_action_layout_render_before_page_layout_handle -->
<method name="otherMethodNameHere" sort="20" class="Class\Name\Here" /><!-- this will call the method Class\Name\Here::otherMethodNameHere on the event controller_action_layout_render_before_page_layout_handle -->
</methods>
</page>
如果缺少 class
属性,它将调用来自 Easylife\Breadcrumbs\Model\Observer
类的方法。
教育
您可以用这个模块来学习。它展示了如何创建配置加载器(我希望我做得对)。
它还展示了如何使用 di.xml
。所有事件的观察者都是 Easylife\Breadcrumbs\Model\Observer\ObserverInterface
,而 di.xml
文件包含对此接口的偏好。
<preference for="Easylife\Breadcrumbs\Model\Observer\ObserverInterface" type="Easylife\Breadcrumbs\Model\Observer" />