企业🤖AI智能体构建引擎,智能编排和调试,一键部署,支持私有化部署方案 广告
# 插件导航条 ## 插件顶部导航条 #### 1、在 `Plugin.php`目录中使用`plugin.yaml`注册导航条 #### 2、 `Plugin.php`中使用`registerNavigation`注册导航条 #### 3、 `Plugin.php`中使用`registerNavigation`注册导航条优先于`plugin.yaml`注册导航条 #### 4、导航条使用 在控制器构造方法`__construct`中使用 - 控制器中使用导航条 ``` namespace Wang\Test2\Controllers; use Backend\Classes\Controller; use BackendMenu; class Notice extends Controller { public function __construct() { parent::__construct(); BackendMenu::setContext('Wang.Test2', 'test2'); } function index() { return time(); } } ``` - plugin.yaml代码示例 ``` plugin: name: 'wang.test1::lang.plugin.name' description: 'wang.test1::lang.plugin.description' author: wang icon: oc-icon-adn homepage: '' navigation: main-menu-item: label: 自定义 url: wang/test2/notice/index icon: icon-adn sideMenu: ... ... ``` ``` - `Plugin.php`的示例`registerNavigation` ``` <pre class="calibre16">``` public function registerNavigation() { return [ 'test' => [ 'label' => '测试', 'url' => Backend::url('wang/test/users/index'), 'icon' => 'icon-pencil', 'iconSvg' => 'plugins/rainlab/blog/assets/images/blog-icon.svg', 'permissions' => ['rainlab.blog.*'], 'order' => 300, 'sideMenu' => [ 'new_post' => [ 'label' => 'rainlab.blog::lang.posts.new_post', 'icon' => 'icon-plus', 'url' => Backend::url('wang/test/users/index'), 'permissions' => ['rainlab.blog.access_posts'], ], 'posts' => [ 'label' => 'rainlab.blog::lang.blog.posts', 'icon' => 'icon-copy', 'url' => Backend::url('rainlab/blog/posts'), 'permissions' => ['rainlab.blog.access_posts'], ], 'categories' => [ 'label' => 'rainlab.blog::lang.blog.categories', 'icon' => 'icon-list-ul', 'url' => Backend::url('rainlab/blog/categories'), 'permissions' => ['rainlab.blog.access_categories'], ], ], ], ]; } ``` ```