首页 > 解决方案 > Laravel 模板结构允许单独的模板文件夹?

问题描述

我有一个正常的 laravel 安装,这意味着我的刀片文件都可以在以下位置找到:

/laravel/resources/views

我想创建另一个文件夹,最好在这个位置:

/templates

并具体有:

/templates/myCustomTheme

如果我有 breadcrumb.blade.php 位于:

/laravel/resources/views/breadcrumb.blade.php

而且我还有:

/templates/myCustomTheme/breadcrumb.blade.php

然后我希望 laravel 改用后一个 myCustomTheme 面包屑文件。

关于从哪里开始做正确的任何想法?

谢谢!

标签: phplaravel

解决方案


你可以使用这个包

https://github.com/石浦/themevel

由于此软件包支持许多需要多主题支持的功能

Custom theme path
Override theme
Parent theme support
Unlimited Parent view finding
Asset Finding
Theme translator support
Multiple theme config extension
Multiple theme changelog extension
Artisan console commands
Theme enable only Specific route via middleware
Almost everything customizable
Also Laravel 7.0+, 8.0+ Support

要切换当前主题,您可以根据您的要求在服务提供商或中间件中使用 set 方法

Theme::set('theme-name');

推荐阅读