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

Render template and send via API

Discussion in 'XenForo Development Discussions' started by SurferJon, Apr 25, 2014.

  1. SurferJon

    SurferJon Member

    Hi, I'm coding some new stuff in an integration I'm doing between Xenforo and Wordpress, in this case I'm using the RESTful API ([bd] API 1.2.1b)

    Link: http://xenforo.com/community/resources/bd-api.1732/

    The problem I have is that I need to render a template from XF and send the resulting HTML via the API, but I can't create a template renderer and I need a bit of help with this:

    This is how I create a template renderer in a normal Controller:

    Code:
    class Route_To_Controller extends XenForo_FrontController {
    
    public function whateva() {
            $controllerResponse = $this->dispatch($routeMatch);
            $controllerResponse = new XenForo_ControllerResponse_View(); 
            $controllerResponse->templateName = $template_name;
            $controllerResponse->viewName = $viewName;
            $controllerResponse->params = $viewParams;
            $containerParams = array('whatever' => 1);
    
            $viewRenderer = $this->_getViewRenderer('html');
            $html = $this->renderView($controllerResponse, $viewRenderer, $containerParams);
    }
    }
    
    Now the API has this structure in the controllers

    Code:
    class bdApi_ControllerApi_Thread extends bdApi_ControllerApi_Abstract
    {
    ...
    
    And bdApi_ControllerApi_Abstract extends XenForo_ControllerPublic_Abstract

    I think I can instantiate $controllerResponse = new XenForo_ControllerResponse_View(); but seems that I can't create $viewRenderer = $this->_getViewRenderer('html'); because that function simply doesn't exist.

    My question is, how can I get the $viewRenderer or how can I get the template from this kind of controller?

    Thank you.
     
  2. SurferJon

    SurferJon Member

    Anyone have an idea? Thanks!
     

Share This Page