[FIX] Add custom preview

S4m'

Active member
Hello :oops:
I have a problem I try to display a preview of a custom editor and it gives me no return.

My action preview on my ControllerPublic
PHP:
   public function actionPreview()
    {
    $this->_assertPostOnly();
    $message = $this->getHelper('Editor')->getMessageText('content', $this->_input);
    $message = XenForo_Helper_String::autoLinkBbCode($message);
    $viewParams = array(
    'message' => $message
    );
    return $this->responseView('AddonCustoms_ViewPublic_Edit', 'Edit_preview', $viewParams);
    }

My renderHtml on my ViewPublic

PHP:
class AddonCustoms_ViewPublic_Preview extends XenForo_ViewPublic_Base
{
    public function renderHtml()
    {
        $bbCodeParser = XenForo_BbCode_Parser::create(XenForo_BbCode_Formatter_Base::create('Base', array('view' => $this)));
        $this->_params['messageParsed'] = new XenForo_BbCode_TextWrapper($this->_params['content'], $bbCodeParser);
    }
}

My template preview

HTML:
<div class="section">
    <h3 class="subHeading">{xen:phrase preview}</h3>
    <div class="messageText primaryContent baseHtml">{xen:raw $messageParsed}</div>
</div>


upload_2016-11-13_11-0-0.webp



Thank you for your help :unsure:
 
Looking at your controller code, it looks like this code in the view:
PHP:
$this->_params['content']

Should be:
PHP:
$this->_params['message']

Content is the name of your editor, but the plain message is passed into the params as 'message'.
 
I changed
PHP:
$this->_params['messageParsed'] = new XenForo_BbCode_TextWrapper($this->_params['message'], $bbCodeParser);

And nothing changes:cry:
 
Your responseView $viewName doesn't match the Class name of your view file (the one posted above in this thread).

Along with the changes that Chris suggested, Change this:
PHP:
return $this->responseView('AddonCustoms_ViewPublic_Edit', 'Edit_preview', $viewParams);

To this:
PHP:
return $this->responseView('AddonCustoms_ViewPublic_Preview', 'Edit_preview', $viewParams);
 
Your responseView $viewName doesn't match the Class name of your view file (the one posted above in this thread).

Along with the changes that Chris suggested, Change this:
PHP:
return $this->responseView('AddonCustoms_ViewPublic_Edit', 'Edit_preview', $viewParams);

To this:
PHP:
return $this->responseView('AddonCustoms_ViewPublic_Preview', 'Edit_preview', $viewParams);
Omg !! thanks youu(y)(y)(y)(y)

bb3b078a7d8846a69de71799a2cce65d.png
 
Last edited:
Top Bottom