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

Parser Problem

Discussion in 'XenForo Development Discussions' started by ragtek, Jan 18, 2011.

  1. ragtek

    ragtek Guest

    We're trying to parse the message, but it isn't working:(

    This is the viewcode:

    PHP:
    class Ragtek_Suggestions_View extends XenForo_ViewPublic_Base
    {
        public function 
    renderHtml(){
            
    $bbCodeParser = new XenForo_BbCode_Parser(XenForo_BbCode_Formatter_Base::create('Base', array('view' => $this)));
            
    $bbCodeOptions = array(
                
    'states' => array(
                    
    'viewAttachments' => false
                
    )
            );
            
    XenForo_ViewPublic_Helper_Message::bbCodeWrapMessages($this->_params['threads'], $bbCodeParser$bbCodeOptions);
        }
    }
    $this->_params['threads'] contains:
    Code:
    [SIZE=4][FONT=Times New Roman]Array
    (
        [0] => Array
            (
                [thread_id] => 74
                [node_id] => 5
                [title] => foo bar
                [reply_count] => 0
                [view_count] => 3
                [user_id] => 38
                [username] => daniel123w
                [post_date] => 1295352522
                [sticky] => 0
                [discussion_state] => visible
                [discussion_open] => 1
                [discussion_type] => 
                [first_post_id] => 81
                [first_post_likes] => 1
                [last_post_date] => 1295352522
                [last_post_id] => 81
                [last_post_user_id] => 38
                [last_post_username] => daniel123w
                [message] => [SIZE=3][FONT=arial][COLOR=rgb(0, 0, 0)][I][B]Lorem ipsum[/B][/I] dolor sit amet, consectetur, adipisci velit[/COLOR][/FONT][/SIZE]
                [attach_count] => 0
                [post] => Array
                    (
                        [post_id] => 81
                    )
            )
        [1] => Array
            (
                [thread_id] => 73
                [node_id] => 5
                [title] => user group permissions for invite add-on
                [reply_count] => 0
                [view_count] => 1
                [user_id] => 1
                [username] => ragtek
                [post_date] => 1295352299
                [sticky] => 0
                [discussion_state] => visible
                [discussion_open] => 1
                [discussion_type] => 
                [first_post_id] => 80
                [first_post_likes] => 0
                [last_post_date] => 1295352299
                [last_post_id] => 80
                [last_post_user_id] => 1
                [last_post_username] => ragtek
                [message] => I'd like to be possible to allow only specific usergroups to invite users
                [attach_count] => 0
                [post] => Array
                    (
                        [post_id] => 80
                    )
            )
    Anybody have some tipps?:)
    [/FONT][/SIZE]
     
  2. ragtek

    ragtek Guest

    ok so it's working BUT is there no way to parse all at once, without foreach?
    PHP:
    <?php
    class Ragtek_Suggestions_View extends XenForo_ViewPublic_Base
    {
        public function 
    renderHtml(){
            
    $bbCodeParser = new XenForo_BbCode_Parser(XenForo_BbCode_Formatter_Base::create('Base', array('view' => $this)));
            
    $bbCodeOptions = array(
                
    'states' => array(
                    
    'viewAttachments' => false
                
    )
            );

                    
    $formatter XenForo_BbCode_Formatter_Base::create();
                    
    $parser = new XenForo_BbCode_Parser($formatter);



                    foreach (
    $this->_params['threads'] AS &$thread){
                        
    $thread['message'] = $parser->render($thread['message']);
                    }
            
    #XenForo_ViewPublic_Helper_Message::bbCodeWrapMessages($this->_params['threads'], $bbCodeParser, $bbCodeOptions);
        
    }
    }
     
  3. Kier

    Kier XenForo Developer Staff Member

    The code you posted using bbCodeWrapMessages($this->_params['threads']...); should work, what was it not doing?

    See XenForo_ViewPublic_Thread_View or XenForo_ViewPublic_Conversation_View for other views that do the job you want.
     
  4. ragtek

    ragtek Guest

    Yes, i've seen it, that's why i tried it this way, but $thread['message'] was still unparsed.
     
  5. Kier

    Kier XenForo Developer Staff Member

    $thread['message'] will remain untouched for reference purposes. Look for a new key called $thread['messageHtml'], to be included with {xen:raw $thread.messageHtml}.
     
    1 person likes this.
  6. ragtek

    ragtek Guest

    ok, problem solved:)

    i thought the parsed message would be in 'message'
     

Share This Page