Call to an action inside a page

Fuhrmann

Well-known member
Is there a way to call to an action, let's say actionIndex in the XenForo_ControllerPublic_Forum and return the response to a var inside a page (using the callbacks for pages)?
 
I could get it to work, I just do not know if this is the correct way:

PHP:
/* Create a new request */
$request = new Zend_Controller_Request_Http();
 
/* The ID of the forum to show. In this example, we'll show the forum with the ID 2*/
$request->setParam('node_id', 2);
 
/* Create a new response */
$responseForum = new Zend_Controller_Response_Http();
 
/* New RouteMatch to use when instance the new ControllerPublic */
$routeMatch = new XenForo_RouteMatch();
 
/* The controller that holds the action that we want to call: XenForo_ControllerPublic_Forum */
$controllerForum = new XenForo_ControllerPublic_Forum($request, $responseForum, $routeMatch);
 
/* Pre Dispatch the controller with the actionIndex */
$controllerForum->preDispatch('index');
 
/* Call the actionIndex in the Controller. This action show a list of threads. (that's what we want) */
$controllerResponse = $controllerForum->{'actionIndex'}();
 
Top Bottom