Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

We've moved the forum!

Please use forum.silverstripe.org for any new questions (announcement).
The forum archive will stick around, but will be read only.

You can also use our Slack channel or StackOverflow to ask for help.
Check out our community overview for more options to contribute.

Archive /

Our old forums are still available as a read-only archive.

Moderators: martimiz, Sean, Ed, biapar, Willr, Ingo

Overloading Page_Controller from a module


Go to End


2 Posts   1361 Views

Avatar
CodeGuerrilla

Community Member, 105 Posts

14 October 2008 at 7:35pm

Edited: 15/10/2008 5:14pm

I am trying to overload my main Page_Controller class from a custom class in a module:

I have made a class module/code/MyPage.php

class MyPage_Controller extends Page_Controller {
   ....
}

In the module _config.php I put:

Object::useCustomClass('Page', 'MyPage');

Doesn't seem to do anything?

If I put the functions in the main Page_Controller website/code/Page.php then they are available, my problem is seeing that these functions belong to the module I would like to keep them separate but they still need to be available to every Page.

Anyone have any ideas on how to achieve this?

Avatar
CodeGuerrilla

Community Member, 105 Posts

16 October 2008 at 12:55pm

Any ideas anyone?

Even better is there a way to add the methods form MyPage_Controller (module) to Page_Controller (project) been playing with: http://api.silverstripe.com/default/Object.html#addMethodsFrom to no avail.