Jump to:

23478 Posts in 18941 Topics by 2878 members

General Questions

SilverStripe Forums » General Questions » obtaining an instance of a controller

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: 812 Views
  • aragonne
    Avatar
    Community Member
    26 Posts

    obtaining an instance of a controller Link to this post

    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

  • 3dgoo
    Avatar
    Community Member
    133 Posts

    Re: obtaining an instance of a controller Link to this post

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

    parent::functionNameHere();

    Just like you do in init:

    parent::init();

  • aragonne
    Avatar
    Community Member
    26 Posts

    Re: obtaining an instance of a controller Link to this post

    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.

    812 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.