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

pass variable to other controller

Go to End

6 Posts   1796 Views


Community Member, 4 Posts

9 May 2012 at 3:21am

Is it possible to call a function which is in the page_controller, from the member controller?

I tried differrent things like:


But I haven't found a nice solution yet.
Is there one?


Forum Moderator, 1391 Posts

9 May 2012 at 5:53am

Edited: 09/05/2012 5:54am


you can instantiate any class, so you could probably do something like:

$myController = new Page_Controller();

In that case there is no referrence to a specific page though, your're just using the Page_Controller class to execute a Page_Controller function. I can't really think of situation where you would need to do that? And you wouldn't want to change core functionality in the member class I would think... So maybe I'm not understanding this correctly?


Community Member, 4 Posts

9 May 2012 at 7:49pm

I tried that, but it doesn't seems to work. Maybe I'm doing something else wrong.
Here is a snippet of my code:

 class SocketServer extends Page_Controller{
    static $allowed_actions = array(
        'delete',  'Delete_tig',

    public function Delete_user(){
        if(this->ID==3) {
            return true;
        return false;


class Employee extends Member {
   public function onBeforeDelete(){

So I'm trying to call the Delete_user() function from my extended Employee class


Forum Moderator, 1391 Posts

10 May 2012 at 10:33pm

I'm sorry, I couldn't get back to you sooner, as my forum login for some reason stopped working. It seems to be OK now, so...

I don't think the Member object has access to a $ParentController property, so unless you defined it somewhere in your Employee class, it probably is never going to pass that filter.

Maybe you could tell me more about what it is you actually want to achieve - there might be an easier way?


Community Member, 4 Posts

10 May 2012 at 11:58pm

No problem :) I had the same problem, thnx for getting back!

I'm pretty new to silverstripe and I think I'm not understanding te sturcture good enough yet.
What I would like to achieve is this:

If a user is deleted, the onBeforeDelete() is called. With function I would like to call the Delete_user() function which then creates a TCP connection to another device in which the user also has to be deleted.

Currently I have written the Delete_user() function in the SocketServer class which extends the Page_controller. Is that the right way to do it?
Or should I make SocketServer an extension which can be called from my Employee class? If so how am I able to call the function in the extension from my employee class?


Forum Moderator, 1391 Posts

11 May 2012 at 12:50am

Edited: 11/05/2012 12:52am

As for the SocketServer extending Page_Controller - I probably wouldn't do that. A Page_Controllers main task, I guess, is to control how a page behaves. Being a SocketServer wouldn't really be part of that. Speaking for my self here, of course :-)

I don't know if you're using specific SilverStripe functionality to build your socketserver connection functionality. If so, then you should make sure your SocketServer class extends whatever class is needed to support that functionality. Otherwise Object [EDIT] or none?[/EDIT] would even be enough...

The following should work:

$socketServerObj = new  SocketServer();
$result = $socketServerObj->DeleteUser($SomeIdentification);