domprojects/codeigniter4-breadcrumb
最新稳定版本:v1.0.1
Composer 安装命令:
composer require domprojects/codeigniter4-breadcrumb
包简介
Breadcrumb builder and controller integration for CodeIgniter 4 projects.
README 文档
README
Breadcrumb builder and controller integration for CodeIgniter 4 projects.
Features
- Reusable breadcrumb builder service
- Ordered breadcrumb items with a single active item
- Named templates for different application areas
- Optional trait for controller integration
- Compatible with CodeIgniter 4.7.2+
Installation
Install the package with Composer:
composer require domprojects/codeigniter4-breadcrumb
Basic Usage
Create and render a breadcrumb manually:
<?php $breadcrumb = single_service('breadcrumb'); $breadcrumb ->add('Home', url_to('home')) ->add('Blog', url_to('blog.index')) ->add('Article'); echo $breadcrumb->render();
Controller Integration
The package includes a HasBreadcrumb trait to simplify breadcrumb handling in controllers.
<?php namespace App\Controllers; use domProjects\CodeIgniterBreadcrumb\Traits\HasBreadcrumb; use CodeIgniter\Controller; abstract class BaseController extends Controller { use HasBreadcrumb; }
Example in a controller:
<?php $this ->breadcrumbRoot('Home', url_to('home')) ->breadcrumbController('Blog', 'blog.index') ->breadcrumbAppend('Article'); $data['breadcrumb'] = $this->renderBreadcrumb();
Templates
Default config ships with three template names:
defaultfrontendbackend
Get a configured template in a controller:
<?php $data['breadcrumb'] = $this->renderBreadcrumb( $this->getBreadcrumbTemplate('backend') );
Package Structure
src/
Breadcrumb.php
Config/
Breadcrumb.php
Services.php
Traits/
HasBreadcrumb.php
License
MIT
统计信息
- 总下载量: 6
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 5
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2026-04-02