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're retiring the forums!

The SilverStripe forums have passed their heyday. They'll stick around, but will be read only. We'd encourage you to get involved in the community via the following channels instead:

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

obtaining an instance of a controller


Go to End


3 Posts   1262 Views

Avatar
aragonne

Community Member, 26 Posts

21 July 2010 at 11:41am


Hi,

I have a class where I want to be able to get an instance of it's parent's controller class.

In the class' controller, I tried:

$myParent = $this->parent();

but it returns the model. Is there anything similar to $this->parent_controller()? I searched the forums but couldn't find anything or didn't use the correct keywords.

thanks!
Steve

Avatar
3dgoo

Community Member, 135 Posts

21 July 2010 at 12:42pm

Any parent function you may need, you can call with:

parent::functionNameHere();

Just like you do in init:

parent::init();

Avatar
aragonne

Community Member, 26 Posts

21 July 2010 at 8:45pm

thanks ampedup, but I should've been more specific in that I was trying to get the parent object with respect to the folder tree and not the class that it extends from.