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

Discussion in 'XenForo Development Discussions' started by Fuhrmann, Dec 8, 2011.

  1. Fuhrmann

    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)?
     
  2. Fuhrmann

    Fuhrmann Well-Known Member

    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'}();
     
    Floris likes this.

Share This Page