cvepdb/laravel-themes

此包已被废弃且不再维护。作者建议使用 cvepdb/laravel-themes 包。

laravel 框架的主题系统

2.3.1 2016-10-07 10:35 UTC

README

Build Status

官方文档位于 这里

安装

打开您的 composer.json 文件,并添加新的必需包。

"pingpong/themes": "~2.1"

然后,打开终端并运行。

composer update

然后,在 config/app.php 中添加新的服务提供者。

'Pingpong\Themes\ThemesServiceProvider',

然后,在 config/app.php 中添加新的别名。

'Theme' => 'Pingpong\Themes\ThemeFacade',

然后,发布包的资产。

php artisan vendor:publish

完成。

用法

获取所有主题。

Theme::all();

设置主题为活动状态。

Theme::set('default');

Theme::setCurrent('default');

获取当前活动主题。

Theme::getCurrent();

检查主题。

Theme::has('simple')

Theme::exists('other-theme');

设置主题路径。

$path = public_path('themes');

Theme::setPath($path);

获取主题路径。

Theme::getThemePath('default');

获取主题路径。

Theme::getPath();

从当前活动主题获取视图。

Theme::view('index');

Theme::view('folders.view');

从活动主题获取翻译值。

Theme::lang('group.name');

从活动主题获取配置值。

Theme::config('filename.key');

Theme::config('filename.key.subkey');

Theme::config('filename.key.subkey', 'default value here');

如果您的主题配置文件名为 config.php,您可以通过配置文件稍微简短地获取值。

Theme::config('key');

Theme::config('key.subkey');

您还可以从其他主题获取配置值。

// current theme
Theme::config('key');

// from other theme
Theme::config('bootstrap::key');

Artisan 命令

生成新的主题。

php artisan theme:make foo

显示所有可用的主题。

php artisan theme:list

缓存所有主题。

php artisan theme:cache

从所有主题发布所有主题资产。

php artisan theme:publish

从指定的主题发布所有主题资产。

php artisan theme:publish theme-name