codewithtony / larathemes
Laravel 5主题管理器
1.2
2017-04-01 19:07 UTC
Requires
- php: >=5.4.0
- laravel/framework: 5.*
This package is not auto-updated.
Last update: 2024-09-14 18:26:17 UTC
README
Laravel 5的最简单主题切换
安装
Laravel 5.1+
安装Laravel主题管理器
composer require codewithtony/larathemes
在config/app.php
中添加服务提供者和外观
'providers' => [ Tony\Themes\ThemeServiceProvider::class, ] //... 'aliases' => [ 'Theme' => Tony\Themes\Themes\ThemeFacade::class, ]
使用
推荐结构
themes
├── [theme name]
| └── assets
| └── views
|
└── [theme name]
└── assets
└── views
设置主题
更改主题很简单
Theme::set('my-theme')
轻松使用中间件更改整个组的主题
Route::group(['prefix' => 'admin', 'middleware' => ['auth', 'theme:admin'], function () { //... });
调用视图
像平常一样加载视图,Laravel主题将在设置的主题中查找您的视图,如果没有找到,视图查找将保持不变
您可以通过将视图存储在主题外重用视图,只需使用 view('layout.master'),并将 layout/master.blade.php 放置在您的主题中。
资源
您的资源仍然需要发送到您的公开文件夹。
贡献
您的帮助非常受欢迎!
许可
根据MIT许可证(MIT)许可。有关更多信息,请参阅LICENSE。