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

Trying to display post in front (attachment/image)

Discussion in 'XenForo Development Discussions' started by Ghostaunt, Apr 22, 2015.

  1. Ghostaunt

    Ghostaunt Active Member

    hello !

    I'm trying to display post in the front of my website. It work, but not for attachments.
    Image are not displayed, and I have "view attachment x"

    Here a screen to the issue

    And on my forum I have the image.

    My code :
    public function getTopic($topic_id)
            $topic = XenForo_Model::create('XenForo_Model_Thread')->getThreadById($topic_id, array('join' => XenForo_Model_Thread::FETCH_FIRSTPOST));
            $formatter = XenForo_BbCode_Formatter_Base::create();
            $parser = new XenForo_BbCode_Parser($formatter);
            $topic['message_html'] = $parser->render($topic['message']);
            return $topic;
    I've tried to find a solution, but found nothing...
    Thanks for your help !
  2. LPH

    LPH Well-Known Member

    Have you looked at XenForo_Model_Attachment?
  3. Ghostaunt

    Ghostaunt Active Member

    Yep, but I think it's in the XenForo_ViewPublic_Thread_View model. I think i have to do the same thing as here but I don't know how
    class XenForo_ViewPublic_Thread_View extends XenForo_ViewPublic_Base
        public function renderHtml()
            $bbCodeParser = XenForo_BbCode_Parser::create(XenForo_BbCode_Formatter_Base::create('Base', array('view' => $this)));
            $bbCodeOptions = array(
                'states' => array(
                    'viewAttachments' => $this->_params['canViewAttachments']
                'contentType' => 'post',
                'contentIdKey' => 'post_id'
            XenForo_ViewPublic_Helper_Message::bbCodeWrapMessages($this->_params['posts'], $bbCodeParser, $bbCodeOptions);
            if (!empty($this->_params['canQuickReply']))
                $draft = isset($this->_params['thread']['draft_message']) ? $this->_params['thread']['draft_message'] : '';
                $this->_params['qrEditor'] = XenForo_ViewPublic_Helper_Editor::getQuickReplyEditor(
                    $this, 'message', $draft,
                        'autoSaveUrl' => XenForo_Link::buildPublicLink('threads/save-draft', $this->_params['thread']),
                        'json' => array('placeholder' => 'reply_placeholder')
    Last edited: Apr 27, 2015
    LPH likes this.
  4. Ghostaunt

    Ghostaunt Active Member

    Nobody ? :(
  5. Ghostaunt

    Ghostaunt Active Member

    always waiting help please

Share This Page