1 (edited by xconspirisist 2005-10-16 09:44)

Topic: BBCode - UL List support.

Here is a mod I've just written for my forum to support basic lists in bbcode. This is my first released mod. Put this in include/parser.php. Just below the normal array lists. Try about line 320.

    if (strstr($text, "[list]") == true) {
        $pattern[] = '#\[list]#';
        $pattern[] = '#\[/list]#';
        $pattern[] = '#\\+(.*?)\\n#';
        $replace[] = '<ul class = "post-list">';
        $replace[] = '</ul>';
        $replace[] = '<li>$1</li>';
    }

Then structure your lists something like:

  • + item 1
    + item 2
    + item 3

Note 1: the code is contained within an IF statment, to check that a [list] tag exists, before it replaces <li> on list items. This is because, someone could have a + at the begining of a new line, and it would therefore be converted to a bullet point.

Note 2: Check the html output of your page to test the mod works, because bullet points might not show up as a result of CSS. You might need to add your own rules. Something like:

UL.post-list {
    list-style: square;
}

Anyway, let me know how you get on with the code.