[FIX] Add custom preview

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



Thank you for your help :unsure:
 

Chris D

XenForo developer
Staff member
#2
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'.
 

Bob

Well-known member
#4
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);
 
#5
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)

 
Last edited:
Top