I converted my SMF site to a Drupal site, I imported the posts to work with the BBCode filter, but I have the BBCode filter disabled for non administrators. What I would like to do is one of two options.

The first is to allow users to be able to edit thier posts, and asked to select a different text format available to them, filtered html, when editing any posts originally saved as BBCode.

The second and preferred option is a way to convert the bbcode posts into actual html posts by rendering each post/comment with the bbcode filter, and re saving them with the filtered html.

Any help is appreciated :)


paulhudson’s picture

An option would be to:

$nids = Load nid's from an SQL query
$nodes = node_load($nids);

foreach ($nodes as $node) {

$bbcode_body = $node->body;

// Then something like this (would need work I'm just slinging the idea in here)
// For a start you'd need to load the $filter object
$filtered_html_body = _filter_html($bbcode_body, $filter);

$node->body = $filtered_html_body;