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.

General Questions /

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

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

How to get a controller from it's page?

Go to End



Community Member, 20 Posts

4 May 2012 at 3:01am

Edited: 04/05/2012 3:56pm

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?