PDA

View Full Version : Parse Custom BBcode on External Pages


Cadellin
12-06-2010, 08:22 PM
I suspect there maybe a solution somewhere for this but after a day of searching and failed attempts I felt it was time to ask.

This is the code I'm using at the moment:
if (!is_object($bbcode_parser))
{
require_once(DIR . '/includes/class_bbcode.php');
$bbcode_parser =& new vB_BbCodeParser($GLOBALS['vbulletin'], fetch_tag_list(),true);
}
$taskdesc = strip_tags($taskdesc);
$taskdesc = $bbcode_parser->parse($taskdesc,0,true);


Which works fine for the default BBcode but I can't get any custom code to work.

If someone could point out where I'm going wrong I'd really appreciate it as this is doing my head in!

Cheers

Hippy
12-06-2010, 08:36 PM
try this .. I am not sure what code is older.. worth a shot
try this replacing this line
$bbcode_parser =& new vB_BbCodeParser($GLOBALS['vbulletin'], fetch_tag_list(),true);
$bbcode_parser =& new vB_BbCodeParser($vbulletin, fetch_tag_list());

Cadellin
12-06-2010, 08:38 PM
Thanks but no change, both work for default BBcode but not for custom.

--------------- Added 1291729000 at 1291729000 ---------------

Solved: Here is an explanation for anyone else hunting for this in the future - it really is simple once you know :)

if (!is_object($bbcode_parser))
{
require_once(DIR . '/includes/class_bbcode.php');
$bbcode_parser =& new vB_BbCodeParser($vbulletin, fetch_tag_list(),true);

$taskdesc = strip_tags($taskdesc);
$taskdesc = $bbcode_parser->parse($taskdesc,0,true);
}

All that is required is to an extra true after the fetch_tag_list() (highlighted in red). Thanks to the excellent code documentation on vB_BbCodeParser (http://members.vbulletin.com/api/vBulletin/vB_BbCodeParser.html#$custom_fetched)

Hippy
12-07-2010, 06:56 PM
thanks for adding your fix ..
but your code is the same as what you posted
except
you added code i posted + true .. and there is a
} missing..

so i am confused

Cadellin
12-07-2010, 07:26 PM
I hadn't actually noticed that - going back and trying it again my original code should have worked and it was something else breaking it when I originally posted and by the time I substituted yours I must have fixed it without realising.

The key point though is that to enable custom BBcode you need to put a true after fetch_tags_list

Hippy
12-08-2010, 01:23 AM
thanks for the info 2 thumbs up