Jump to:

5537 Posts in 1737 Topics by 1223 members

Customising the CMS

SilverStripe Forums » Customising the CMS » Pass Request to another Controller

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

Page: 1
Go to End
Author Topic: 356 Views
  • juergr
    Avatar
    Community Member
    17 Posts

    Pass Request to another Controller Link to this post

    Is it possible to pass the whole Request to another Controller from within a Controller action?

    Lets say we have something like this:

    The First Controller:

    class Controller1 extends Page_Controller {
    public static $url_handlers = array(
    '$Action/$ID' => 'doStuff'
    )

    function doStuff($request) {
    if($request->param['Action'] == 'special') {
    // Pass control to my SpecialController
    }
    return $this;
    }
    }

    The Special Controller

    class SpecialController extends Page_Controller {
    public static $url_handlers = array('$ID' => 'display');

    public function display($request) {
    return $this;
    }
    }

    How can I do something like this? I've tried it with

    return new SpecialController();

    and

    $controller = new SpecialController();
    return $controller->handleRequest($request);

    But all I get is:

    [User Warning] popCurrent called on ModelAsController controller, but it wasn't at the top of the stack

    Any solutions for this?

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