• This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn more.

Call to an action inside a page

Fuhrmann

Well-known member
#1
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)?
 

Fuhrmann

Well-known member
#2
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'}();