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

BBCode Parsing

Discussion in 'XenForo Development Discussions' started by Mythotical, Jun 28, 2011.

  1. Mythotical

    Mythotical Well-Known Member

    Ok so I figured out thanks to Jaxel that I need to include parsing in my ViewPublic file.

    So I keep getting this error:
    This is my ViewPublic file:
    class xPortal_ViewPublic_Portal extends XenForo_ViewPublic_Base
        public function 
    // Get the blocks info in a local variable
    $blocks $this->_params['blocks'];

    // We don't need the blocks being passed to individual templates

    // These are the params that'll be passed to the child templates
    $params $this->_params;

    // Initialize the arrays keys for storing block content
    $this->_params['leftBlocks'] = '';
    $this->_params['midBlocks'] = '';
    $this->_params['rightBlocks'] = '';

            foreach (
    $blocks['left'] AS $left)
    $this->_params['leftBlocks'] .= $this->createTemplateObject($left['temp_template'], $params);

            foreach (
    $blocks['mid'] AS $mid)
    $mid .= $this->createTemplateObject($mid['temp_template'], $params);
    $bbCodeParser = new XenForo_BbCode_Parser(XenForo_BbCode_Formatter_Base::create('Base', array('view' => $this)));
    $bbCodeOptions = array('viewAttachments' => true);
    $this->_params['midBlocks'] = new XenForo_BbCode_TextWrapper($mid$bbCodeParser$bbCodeOptions);

            foreach (
    $blocks['right'] AS $right)
    $this->_params['rightBlocks'] .= $this->createTemplateObject($right['temp_template'], $params);

    I removed the code for a simpler view, but I'm trying to use this:

    Not sure where I can place this without it breaking. I'm trying to parse bbcode used in the news block when it pulls a thread using bbcode but needs to parse no matter which column its in. So any help with this would be great as this is the last step before RC release.

  2. ragtek

    ragtek Guest

    public static function bbCodeWrapMessages(array &$messages, XenForo_BbCode_Parser $parser, array $options = array())

    1. param have to be a array.
    And it seems that your var was empty/null or not a array
  3. Mythotical

    Mythotical Well-Known Member

    Ragtek, don't take this the wrong way but I have been over that code, I have read and read, seriously, stop with the Yoda and just give me some input.

    And your stating the obvious, I already know the array issue but I'm new to the BBCode stuff with XenForo so I'm at a loss when it comes to that stuff.
  4. Jeremy

    Jeremy Well-Known Member

    And you again are requesting help without giving enough information. Based on the code you provided: the view and and what you want the BBcode to be parsed using. Ragtek's reply was the only possible solution because you haven't shown us where the main variable is set. Provide that, and we can quit being "yoda" and give you some input.
    Forsaken likes this.
  5. Mythotical

    Mythotical Well-Known Member

    I have KK, all variables are defined in the file that I placed in the PHP tags. Shows how much you read. lol
  6. Jeremy

    Jeremy Well-Known Member

    The only definition for $singleText is this:
    $singleText = new XenForo_BbCode_TextWrapper($singleText$bbCodeParser$bbCodeOptions);
    If that's true, reread Ragtek's post. He answers you perfectly fine. If $singleText is defined else where for you in the code, you're missing crucial information.
  7. Mythotical

    Mythotical Well-Known Member

    $singleText is only example vars. Sheesh, figured that would be obvious as I was describing what the variable would be technically aiming to do.
  8. Mythotical

    Mythotical Well-Known Member

    Ok I have added the BBCode parser into the file as you can see above. Assigned a new variable, and got a result, smilies are parsed but now it doesn't parse the rest. Screenshot provided.

  9. Mythotical

    Mythotical Well-Known Member

    All that is held in the database is the template name so should I be parsing it before doing the template object stuff?
  10. Jeremy

    Jeremy Well-Known Member

    Is there actual BBCode in the template? Is it something like the help templates for BBCodes where the template actually stores / holds BBCode rather than the database? Or are you placing text from the DB (say latest news) into a template? If that's the case, you're using the wrong class.
  11. Mythotical

    Mythotical Well-Known Member

    Yes exactly, using Latest News block which is just a template name in the database. The file pulls that and converts it to a usable source to be passed to the main page. So could you point me towards the right code and such for doing this on the latest news block?
  12. Jeremy

    Jeremy Well-Known Member

    If I'm correct, you are using the wrong formatter. The way you described, you are placing BBCode into the template, but fetching the actual news from the DB? If so, you need to use XenForo_BbCode_Parser_Base::render() and it should in theory work. Then you insert the parsed text into the template object ($viewParam would be the best idea here).
  13. Mythotical

    Mythotical Well-Known Member

    Ok so should I put that in my ViewPublic file or use my News model? Either way, what is the proper code I need to use?
  14. Jeremy

    Jeremy Well-Known Member

    :whistle: Then, take the code and insert them into the template using $viewParams parameter.

Share This Page