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

Correctly render Quotations from XenForo_FrontController

Discussion in 'XenForo Development Discussions' started by SurferJon, Jun 17, 2014.

  1. SurferJon

    SurferJon Member

    Good day, I did an integration between XF and Wordpress and I'm using the XenForo_FrontController class to process tha data and render the views.

    My problem is that when I show a post in a view the quotations are simple and not the same as the forum which are more complex, I'm doing this to wrap the messages (Notice that I don't pass a view renderer):

    Code:
    $bbCodeParser = XenForo_BbCode_Parser::create(XenForo_BbCode_Formatter_Base::create('Base'));
            $bbCodeOptions = array(
                'states' => array(
                    'viewAttachments' => $params['canViewAttachments']
                ),
                'contentType' => 'post',
                'contentIdKey' => 'post_id'
            );
           
    XenForo_ViewPublic_Helper_Message::bbCodeWrapMessages($params['posts'], $bbCodeParser, $bbCodeOptions);
    
    And I noticed the following code in the next file:

    File: XenForo_BbCode_Formatter_Base

    Code:
    public function renderTagQuote
    ...
            if ($this->_view)
            {
                $template = $this->_view->createTemplateObject('bb_code_tag_quote', array(
                    'content' => $content,
                    'nameHtml' => $name,
                    'source' => $source,
                    'attributes' => $attributes,
                    'ignored' => (isset($attributes['member']) && isset($this->_ignoredUsers[intval($attributes['member'])]))
                ));
                return $template->render();
            }
            else
            {
                return $this->_renderTagQuoteFallback($name, $content);
            }
    
    So my problem is that I need to pass a viewRenderer to this function and it needs to be an instance of XenForo_View and the view renderer I'm using in this controller is an instance of XenForo_ViewRenderer_HtmlPublic which is not valid, can someone please help me so I can get the correct quotation html when wrapping the messages?

    Thank you.
     
  2. Jeff Berry

    Jeff Berry Well-Known Member

    There's a difference between a view renderer and XenForo_View. You'll need to create a XenForo_ViewPublic_Base class to pass the bbCodeParser.

    Try this:
    PHP:
    // Either use this or use the variable you already have assigned to the FrontController object
    $fc XenForo_Application::getFc();

    // use your XenForo_ViewRenderer_HtmlPublic instance as the first argument here
    $baseView = new XenForo_ViewPublic_Base($viewRenderer$fc->getResponse());
    Now in your existing code you'll want to replace :
    PHP:
    $bbCodeParser XenForo_BbCode_Parser::create(XenForo_BbCode_Formatter_Base::create('Base'));
    With :
    PHP:
    $bbCodeParser XenForo_BbCode_Parser::create(XenForo_BbCode_Formatter_Base::create('Base', array('view' => $baseView)));
    That should get you going.
     

Share This Page