jorisnoo/craft-sidebar-relations
Composer 安装命令:
composer require jorisnoo/craft-sidebar-relations
包简介
Adds nested element sources to the Craft CMS sidebar based on entry relations
README 文档
README
A Craft CMS module that adds nested element sources to the control panel sidebar based on entry relations. Filter a section's entries by their related entries from another section, directly from the sidebar navigation.
Features
- Adds nested sources under any section in the entries sidebar
- Filter entries by their relations to entries in another section
- Supports custom query conditions on the relation source
- Config-based setup with a fluent API
Requirements
- PHP 8.2+
- Craft CMS 5
Installation
composer require jorisnoo/craft-sidebar-relations
Then register the module in your config/app.php:
return [ 'modules' => [ 'sidebar-relations' => \Noo\CraftSidebarRelations\SidebarRelations::class, ], 'bootstrap' => ['sidebar-relations'], ];
Configuration
Create a config/sidebar-relations.php file in your Craft project:
use Noo\CraftSidebarRelations\config\SidebarRelationsConfig; return SidebarRelationsConfig::create() ->sources([ [ 'section' => 'articles', 'relation' => 'categories', ], [ 'section' => 'projects', 'relation' => 'clients', 'where' => [ 'level' => 1, ], ], ]);
Source Options
Each source in the array accepts the following keys:
section— The handle of the section to add nested sources torelation— The handle of the section whose entries will become the nested source itemswhere— (optional) Additional query parameters applied to the relation query (e.g.level,status,orderBy)
In the example above, the "Articles" section in the sidebar would get nested items for each entry in the "Categories" section. Clicking a nested item filters the article list to only show articles related to that category.
License
The MIT License (MIT). Please see LICENSE for more information.
统计信息
- 总下载量: 230
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 0
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2026-03-31