0

All,

I have a structure as follows:

  • Main Application
    • Custom Theme Plugin
    • Plugin with AppController and other Controllers

I am using the custom theme plugin for my main application but the second plugin is defaulting to using the standard CakePHP theme. Is there any way to specify what theme it needs to use without changing the plugin files of the theme itself?

Thanks for your input in advance.

The answer was discovered after reading the selected response below. Answer was as follows I had the following:

class PluginSystemPluginsController extends Controller

It needed to be:

class PluginSystemPluginsController extends AppController

Also the AppController in my plugin was extending Controller and should be

use App\Controller\AppController as BaseController;
class AppController extends BaseController 
KaffineAddict
  • 436
  • 2
  • 11

1 Answers1

0

Plugin's AppController extends your main application's AppController. You can change theme in your main application's AppController.

public function beforeRender(\Cake\Event\Event $event)
{
    $this->viewBuilder()->theme('Modern');
}
user3082321
  • 654
  • 5
  • 12
  • Here is a link to my plugins [AppController](https://github.com/KaffineAddict/PluginSystem/blob/master/src/Controller/AppController.php). I wonder if this is a routing issue in my plugin rather than an issue with the AppController as I still have issues. – KaffineAddict Dec 09 '15 at 03:49
  • Here is a link to the [Routes](https://github.com/KaffineAddict/PluginSystem/blob/master/config/routes.php) would this cause the problem? – KaffineAddict Dec 09 '15 at 04:03
  • Your plugin's `AppController` isn't right. If you are having problem, you can use `bake` to create the plugin. It'll create plugin's `AppController` as well. http://book.cakephp.org/3.0/en/bake/usage.html – user3082321 Dec 09 '15 at 07:00
  • Yep I saw this. You led me to the answer and I edited mine above to show what I changed. Thanks Again! – KaffineAddict Dec 10 '15 at 02:55