A way to get rendered Html of post?

cmpe

Active member
Hi all,

I'm creating a bridge between a CMS <-> XF and trying to reconcile the fact that the CMS uses (pseudo-)HTML and XF uses BbCode.

For now, I'm using XenForo_Html_Renderer_BbCode::renderFromHtml when posts from CMS needs to get written into XF (so CMS Html->XF BbCode). However, I'm wondering if there is a way to get the html (rendered by XF) returned back after the DataWriter saves so that I can save this as the CMS data.

The main reason why I want to be able to do this (please sanity check maybe there's a simpler method), is to allow the CMS users to utilize all BbCode available through XF and the Html to be consistent across both platforms.

So to simplify, if the process flow is:
Code:
pseudo-HTML -> [CMS Processor] -> CMS HTML

I would like to look like this:
Code:
pseudo-HTML -> [XF's renderFromHtml] -> [Save to XF] -> [ Magic Process -> (Final Html from XF) ] -> CMS HTML

Overriding the CMS processor is simple, just need some guidance on the "Magic Process" in the 2nd diagram. Hope this is making some semblance of sense :LOL:

Thanks in advance and appreciate any pointers/suggestions!
 
Last edited:
Think I figured out a way, here's some ugly test code in case anyone wants to know (or better yet, can optimize this):
Code:
        $parser = new XenForo_BbCode_Parser(XenForo_BbCode_Formatter_Base::create('XenForo_BbCode_Formatter_BbCode_AutoLink'));
        $test_parse = $parser->render('[b]testing this[/b] http://xenforo.com');

        $parser = new XenForo_BbCode_Parser(XenForo_BbCode_Formatter_Base::create('XenForo_BbCode_Formatter_Base'));
        var_dump($parser->render($test_parse));

Results in:
Code:
string '<b>testing this</b> <a href="http://xenforo.com" target="_blank" class="externalLink ProxyLink" data-proxy-href="proxy.php?link=http%3A%2F%2Fxenforo.com&amp;hash=1ee2af657cc907b08a1abf15d0b332af" rel="nofollow">http://xenforo.com</a>' (length=233)

Having to go through the AutoLink formatter first then the Base one because haven't been able to figure out how to do it any better.
 
Back
Top Bottom