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

Unable to create thread with html post message

Discussion in 'XenForo Development Discussions' started by rpg999, Apr 1, 2015.

  1. rpg999

    rpg999 New Member

    I am working on synchronizing news from a site and it's forum. So when an admin create some news on the site, a thread would be created in the forum as well. I used XenForo_DataWriter_Discussion_Thread for that.

    $writer = XenForo_DataWriter::create('XenForo_DataWriter_Discussion_Thread');
    $writer->set('user_id', $oUser['user_id']);
    $writer->set('username', $oUser['username']);
    $writer->set('node_id', 2);
    $writer->set('title', $aIns['name_article']);
    $postWriter = $writer->getFirstMessageDw();
    $postWriter->set('message', $aIns['content_article']);
    $writer->save();

    The problem is the after creating a thread, the message is displayed with html tags.

    bug.png

    How can i make it works properly without striping html tags ?
     
  2. Chris D

    Chris D XenForo Developer Staff Member

    Have you considered pulling the news content in automatically using RSS and Registered Feeds?
     
  3. rpg999

    rpg999 New Member

    How can i do it ? It means that i have to write some new module for creating RSS for my site ?
     
  4. Chris D

    Chris D XenForo Developer Staff Member

    Well, there's two things, really.

    Yes, if you had the ability to create an RSS feed for your site (or if your site was built on a platform that supports RSS) then that would be quite easy because XenForo can read that automatically on a schedule, clean up the HTML (it converts it to bb code) and creates a thread in a forum.

    However, if that isn't possible, you could at least look at the part of the XF code that converts the HTML to BB Code. Specifically:

    PHP:
    $entry['content'] = XenForo_Html_Renderer_BbCode::renderFromHtml($html, array(
        
    'baseUrl' => $feed['baseUrl']
    ));
    EDIT:

    I should probably add: there are add-ons in the RM which allow HTML to be parsed inside a special BB code. That might also be an easy option.
     
  5. rpg999

    rpg999 New Member

    Thank you so much , converting the HTML to BB Code works for me :)
     

Share This Page