maiconpinto / cakephp-adminlte-theme

CakePHP AdminLTE Theme
http://maiconpinto.github.io/cakephp-adminlte-theme/
MIT License
174 stars 111 forks source link

Overriding plugin templates doesn't work #107

Open oresch opened 4 years ago

oresch commented 4 years ago

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.

Brandon1811 commented 4 years ago

@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

oresch commented 4 years ago

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 ....

rkhe commented 4 years ago

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.

g-gibosky commented 4 years ago

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

rkhe commented 4 years ago

@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.

ashishonmobile commented 3 years ago

@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 commented 3 years ago

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