Possibility to merge/extend controller from registry

Is it possible to merge or extend a controller set in the registry via a plugin?

I know you can “override” or “discard” the controller by defining a new one with the same name in /site/controllers, but then the logic defined in the plugin controller is discarded. I would like to have some basic functionality in a controller in a plugin that can be “extended” in a “standard” controller without copying code over from the plugin.


At least not that I know of, unless you create a sort of default controller script and then include that file in your site controller.

Darn, I thought so. I would rather not fiddle with default controllers etc as that kinda defeats my purpose of moving code in a plugin (which could be used as an agnostic component to set a functional baseline).

Then maybe rather than using a controller, you can outsource that code into a function or class?

Hmmm, yes. But then I wouldn’t have a “default” controller which is automagically there when there is no local controller defined.

Unless I create a controller in the plugin which simply runs the same function? I’ll give it a try. Thx

For what it’s worth, let me add this link to an old discussion: Inherit Controller - Controllers that inherit from the site controller

No solution for this now? I’m stucking with that too. I found this article. It’s pretty useful. But still, if you use a site controller in your Plugin, it will die if there’s a page controller around.

I made a suggestion for that.

@texnixe Do you have an code example for your…

It all depends on what you are trying to achieve. A lot of functionality can for example go into a page model. So you could for example have a base page model and your dedicated page models would extend this base page model, thus sharing all these methods.

Or you create a data provider class that defines some methods with your logic which you can then reuse in all your controllers or directly in the templates.

Also, you can make extensive use of collections.

It’s nothing that is then automatically loaded everywhere, but on the other you don’t have to overwrite stuff from your shared controller.