Jump to:

17452 Posts in 4473 Topics by 1971 members

Archive

SilverStripe Forums » Archive » Overloading Page_Controller from a module

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

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

Page: 1
Go to End
Author Topic: 1052 Views
  • CodeGuerrilla
    Avatar
    Community Member
    105 Posts

    Overloading Page_Controller from a module Link to this post

    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?

  • CodeGuerrilla
    Avatar
    Community Member
    105 Posts

    Re: Overloading Page_Controller from a module Link to this post

    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.

    1052 Views
Page: 1
Go to Top

Want to know more about the company that brought you SilverStripe? Then check out SilverStripe.com

Comments on this website? Please give feedback.