hoppinger/breadcrumb_builder
Composer 安装命令:
composer require hoppinger/breadcrumb_builder
包简介
Drupal module to build breadcrumbs
README 文档
README
Navigation can greatly enhance the way users find their way around. In terms of usability, breadcrumbs reduce the number of actions a website visitor needs to take in order to get to a higher-level page, and they improve the findability of website sections and pages. They are also an effective visual aid that indicates the location of the user within the website’s hierarchy, making it a great source of contextual information for landing pages.
Installation
composer require hoppinger/breadcrumb_builder
Usage
Path Breadcrumb builder automatically recognizes the correct breadcrumb you want based on the URLs of the pages and the items included in the menu. In case of special breadcrumb trail requirement, you can extend the functionality of the Path breadcrumb builder and create your own breadcrumb trail.
Create a custom service and define the service in the modulename.services.yml file. Replace the ExampleBreadcrumbBuilder with your own filename. Add the priority to the custom breadcrumb builder.
class: Drupal\module_name\ExampleBreadcrumbBuilder arguments: ['@plugin.manager.menu.link'] tags: - { name: custom_breadcrumb_builder, priority: x }
Create a file ExampleBreadcrumbBuilder.php inside the <module_name>/src folder and extend the Breadcrumb manager.
namespace Drupal\<module_name>; use Drupal\breadcrumb_builder\BreadcrumbBuilderInterface; use Drupal\Core\Menu\MenuLinkInterface; use Drupal\Core\Menu\MenuLinkManagerInterface; use Drupal\Core\Routing\RouteMatchInterface; use Drupal\breadcrumb_builder\BreadcrumbResult; class ExampleBreadcrumbBuilder implements BreadcrumbBuilderInterface { //Variables public function __construct() { //Intitialize } /** * {@inheritdoc} */ public function applies(RouteMatchInterface $route_match) { return TRUE; } public function build(RouteMatchInterface $route_match) { //Custom logic } }
In some cases we need more menu types than the specified 'main' menu, to contribute to the breadcrumb generation.
Create a .php file in the module directory /src with the following content. Replace the <target_identifier> with the project-specific menu type that needs to be embedded into the API response (for example: footer)
The <target_identifiers> can be Menu types.
The filename must be similar to the module name i.e., ModuleNameServiceProvider.php and must be placed in the src folder.
use Drupal\Core\DependencyInjection\ContainerBuilder; use Drupal\Core\DependencyInjection\ServiceProviderBase; use Symfony\Component\DependencyInjection\Reference; class AlterServiceProvider extends ServiceProviderBase { public function alter(ContainerBuilder $container) { if ($container->hasParameter('breadcrumb_builder.target_identifiers')) { $target_identifiers = $container->getParameter('breadcrumb_builder.target_identifiers'); $target_identifiers[] = <target_identifier>; #e.g., footer $container->setParameter('breadcrumb_builder.target_identifiers', $target_identifiers); } }
By default, main menu is already added as the target identifier.
hoppinger/breadcrumb_builder 适用场景与选型建议
hoppinger/breadcrumb_builder 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 9.88k 次下载、GitHub Stars 达 2, 最近一次更新时间为 2019 年 09 月 16 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 hoppinger/breadcrumb_builder 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 hoppinger/breadcrumb_builder 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 9.88k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 2
- 点击次数: 7
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: GPL-2.0
- 更新时间: 2019-09-16