更改路径搜索顺序
Change the path search order
这是当前的搜索路径顺序:
Element file aside/user-panel.php could not be found.
The following paths were searched:
[1].../vendor/maiconpinto/cakephp-adminlte-theme/templates/element/aside/user-panel.php
[2].../templates/element/aside/user-panel.php
[3].../vendor/cakephp/cakephp/templates/element/aside/user-panel.php
如何更改顺序,使当前 [2]
优先搜索?
我的意图是不想在原始插件模板中进行编辑。我宁愿将它们复制到项目目录中并在那里进行调整。
编辑
我正在使用 CakePHP 4.1.0
自版本 1.0.6 起自定义布局
/ src/Controller/AppController.php
use Cake\Core\Configure;
public function beforeRender(Event $event)
{
// Overwrite AppView class
$this->viewBuilder()->setClassName('AdminLTE.AdminLTE');
}
在 AppController.php 文件中启用 AdminLTEView class 后,您可以覆盖任何视图文件,只需在模板中创建 Plugin/AdminLTE/ 文件夹文件夹.
例如,要覆盖元素文件,您必须按如下方式创建它们:
- templates/plugin/AdminLTE/element/nav-top.php
- templates/plugin/AdminLTE/element/aside-main-sidebar.php
- templates/plugin/AdminLTE/element/aside/user-panel.php
- templates/plugin/AdminLTE/element/aside/form.php
- templates/plugin/AdminLTE/element/aside/sidebar-menu.php
- templates/plugin/AdminLTE/element/aside-control-sidebar.php
- templates/plugin/AdminLTE/element/footer.php
在插件文档中阅读更多内容:
https://github.com/maiconpinto/cakephp-adminlte-theme/wiki/Customize-Layout
Salines 的答案不适用于 CakePHP 4.x - 请参阅此 upgrade guide。我接受了他的回答,因为 Salines 把我带到了正确的方向,即使它没有 100% 回答,因为我正在寻找一个通用的功能。
正如提到的 link Salines 中所述 https://github.com/maiconpinto/cakephp-adminlte-theme/wiki/Customize-Layout 我现在在这里提供 CakePHP 的正确路径 4.x
templates/plugin/AdminLTE/element/nav-top.php
templates/plugin/AdminLTE/element/aside-main-sidebar.php
templates/plugin/AdminLTE/element/aside/user-panel.php
templates/plugin/AdminLTE/element/aside/form.php
templates/plugin/AdminLTE/element/aside/sidebar-menu.php
templates/plugin/AdminLTE/element/aside-control-sidebar.php
templates/plugin/AdminLTE/element/footer.php
这是当前的搜索路径顺序:
Element file aside/user-panel.php could not be found.
The following paths were searched:
[1].../vendor/maiconpinto/cakephp-adminlte-theme/templates/element/aside/user-panel.php
[2].../templates/element/aside/user-panel.php
[3].../vendor/cakephp/cakephp/templates/element/aside/user-panel.php
如何更改顺序,使当前 [2]
优先搜索?
我的意图是不想在原始插件模板中进行编辑。我宁愿将它们复制到项目目录中并在那里进行调整。
编辑
我正在使用 CakePHP 4.1.0
自版本 1.0.6 起自定义布局
/ src/Controller/AppController.php
use Cake\Core\Configure;
public function beforeRender(Event $event)
{
// Overwrite AppView class
$this->viewBuilder()->setClassName('AdminLTE.AdminLTE');
}
在 AppController.php 文件中启用 AdminLTEView class 后,您可以覆盖任何视图文件,只需在模板中创建 Plugin/AdminLTE/ 文件夹文件夹.
例如,要覆盖元素文件,您必须按如下方式创建它们:
- templates/plugin/AdminLTE/element/nav-top.php
- templates/plugin/AdminLTE/element/aside-main-sidebar.php
- templates/plugin/AdminLTE/element/aside/user-panel.php
- templates/plugin/AdminLTE/element/aside/form.php
- templates/plugin/AdminLTE/element/aside/sidebar-menu.php
- templates/plugin/AdminLTE/element/aside-control-sidebar.php
- templates/plugin/AdminLTE/element/footer.php
在插件文档中阅读更多内容:
https://github.com/maiconpinto/cakephp-adminlte-theme/wiki/Customize-Layout
Salines 的答案不适用于 CakePHP 4.x - 请参阅此 upgrade guide。我接受了他的回答,因为 Salines 把我带到了正确的方向,即使它没有 100% 回答,因为我正在寻找一个通用的功能。
正如提到的 link Salines 中所述 https://github.com/maiconpinto/cakephp-adminlte-theme/wiki/Customize-Layout 我现在在这里提供 CakePHP 的正确路径 4.x
templates/plugin/AdminLTE/element/nav-top.php
templates/plugin/AdminLTE/element/aside-main-sidebar.php
templates/plugin/AdminLTE/element/aside/user-panel.php
templates/plugin/AdminLTE/element/aside/form.php
templates/plugin/AdminLTE/element/aside/sidebar-menu.php
templates/plugin/AdminLTE/element/aside-control-sidebar.php
templates/plugin/AdminLTE/element/footer.php