cakephp-adminlte-theme icon indicating copy to clipboard operation
cakephp-adminlte-theme copied to clipboard

Overriding plugin templates doesn't work

Open oresch opened this issue 4 years ago • 7 comments

Hi. Today I installed a fresh CakePHP 4.0.x and cakephp-adminlte-theme 2 as described here in the wiki. I also added the fix in the AppController as mentioned in #102 . Everything is shown fine. Now I want to override some elements (layout, nav, footer etc) by copying the original default.php /myProject/vendor/maiconpinto/cakephp-adminlte-theme/templates/layout/default.php to the folder to /myProject/templates/plugin/AdminLTE/layout/default.php as described in CakePHP's documentation.

But the modification is not visible. Any ideas? It doesn't matter if I override layout or element etc. No effect at all. Thanks for your support.

oresch avatar Jun 30 '20 12:06 oresch

@oresch I just had the same issue - I solved by copying the entire templates folder from /myProject/vendor/maiconpinto/cakephp-adminlte-theme into /myProject/plugins/CustomAdminLTE and then in AppController beforeRender set the theme to CustomAdminLTE. ie $this->viewBuilder()->setTheme('CustomAdminLTE');

not sure if this is the best way to handle it but it seems to be working

Brandon1811 avatar Jul 01 '20 07:07 Brandon1811

Hi @Brandon1811 . Thanks for your feedback. This sounds like "forking" the original plugin. Yes this could be a way to solve the issue, but it does not solve the reason of it ;-) For testing I will check doing the same, but @maiconpinto should have a look to this as well ....

oresch avatar Jul 01 '20 09:07 oresch

Hi @oresch, I encountered the same issue few months ago and stop migrating to CakePHP 4.0 because of that. But I revisited the issue today and believe to have found the solution.

Add the line of code $this->viewBuilder()->setClassName('AdminLTE.AdminLTE'); in the AppController.cs under public function beforeRender(EventInterface $event) method.

Mine now looks like this.

public function beforeRender(EventInterface $event)
{
    $this->viewBuilder()->setTheme('AdminLTE');
    $this->viewBuilder()->setClassName('AdminLTE.AdminLTE');
}

Hope this helps.

rkhe avatar Aug 25 '20 14:08 rkhe

Here to say that puting the layout folder on /[System Root]/template/Plugin/AdminLTE/layout worked perfectly

I did this to change the login layout.

Thanks

g-gibosky avatar Nov 03 '20 17:11 g-gibosky

@g-gibosky

Your are correct. However in my case, I ran into issues when I deployed to a Linux server regarding the "Plugin" folder. The "P" needs to be in lower-case. Though not sure if it's a server configuration issue or that's how it should be done.

rkhe avatar Nov 04 '20 02:11 rkhe

@g-gibosky

Your are correct. However in my case, I ran into issues when I deployed to a Linux server regarding the "Plugin" folder. The "P" needs to be in lower-case. Though not sure if it's a server configuration issue or that's how it should be done.

I faced also the same issue but this solution does not work. even server does not generate any error "cakephp/cakephp": "4.1.7", "maiconpinto/cakephp-adminlte-theme": "2.0.2",

Regards, Ashish

ashishonmobile avatar Jan 06 '21 18:01 ashishonmobile

Finally I found the solution.

Ans:

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://stackoverflow.com/questions/63174722/change-the-path-search-order/63180817#63180817

For me why it was not working because I was using 'Plugin' as a folder name and 'Element' as a folder name where it should be in lower case only.

Regards, Ashish

ashishonmobile avatar Jan 06 '21 22:01 ashishonmobile