Jump to:

23483 Posts in 18976 Topics by 2878 members

General Questions

SilverStripe Forums » General Questions » How to get a controller from it's page?

General questions about getting started with SilverStripe that don't fit in any of the categories above.

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

Page: 1
Go to End
Author Topic: 477 Views
  • tfliam
    Community Member
    20 Posts

    How to get a controller from it's page? Link to this post

    Currently I am using codes below to get a page's controller from a page:

    //check page existence
    $pagename = 'ContactPage';
    if($page = DataObject::get_one($pagename)) {

    //check method existence
       $page_controller = $pagename . '_Controller';         
       $page_controller = new $page_controller;                                    

       if ($page_controller->hasAction('confirmationEmail')) {      
          return Controller::join_links($page->AbsoluteLink(), 'confirmationEmail');                     


    Is there any more effiecient method?

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.