https://github.com/hongyukeji/laravel-theme
https://github.com/hongyukeji/laravel-theme
Last synced: 5 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/hongyukeji/laravel-theme
- Owner: hongyukeji
- Created: 2019-05-28T01:10:03.000Z (about 6 years ago)
- Default Branch: master
- Last Pushed: 2020-08-11T14:27:43.000Z (almost 5 years ago)
- Last Synced: 2024-04-19T23:03:24.274Z (about 1 year ago)
- Language: PHP
- Size: 10.7 KB
- Stars: 2
- Watchers: 1
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
laravel-theme
Laravel 主题模板功能, 这可能是我用过最优雅的laravel主题扩展
## Installing
```shell
$ composer require hongyukeji/laravel-theme
``````shell
$ php artisan vendor:publish --provider="Hongyukeji\LaravelTheme\ThemeServiceProvider"
```## Usage
### 特点
> 利用 View::addNamespace() 和 View::prependNamespace() 实现主题模板功能
### 使用
```
// 1. 在 config/themes.php 中 添加 templates, 如:
'templates' => [
'frontend' => [
'path' => 'frontend',
'template' => 'default',
'default' => 'default',
],
],// 2. 在控制器中使用:
public function index()
{
return view('frontend::index.index');
}// 3. 在视图目录新建frontend目录和对应的index(frontend => 终端, default => 主题):
resources/views/frontend
resources/views/frontend/default
resources/views/frontend/default/index
resources/views/frontend/default/index/index.blade.php```
### templates 配置说明
- path 为每个终端模板目录路径
- template 为使用模板的目录
- default 为默认模板目录, 即找不到template模板对应的目录文件, 会自动在该参数定义的目录去查找### 助手函数你可能会需要
- get_template_dir 获取给定路径下的所有目录
## Contributing
You can contribute in one of three ways:
1. File bug reports using the [issue tracker](https://github.com/hongyukeji/laravel-theme/issues).
2. Answer questions or fix bugs on the [issue tracker](https://github.com/hongyukeji/laravel-theme/issues).
3. Contribute new features or update the wiki._The code contribution process is not very formal. You just need to make sure that you follow the PSR-0, PSR-1, and PSR-2 coding guidelines. Any new code contributions must be accompanied by unit tests where applicable._
## License
MIT