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.

Archive

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

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

Overloading Page_Controller from a module


Reply

2 Posts   1068 Views

Avatar
CodeGuerrilla

14 October 2008 at 7:35pm (Last edited: 15 October 2008 5:14pm), Community Member, 105 Posts

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

16 October 2008 at 12:55pm Community Member, 105 Posts

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.