15 years on The Web
miniBB ® miniBB®
miniBB Support Forums
 | Forums | Register | Reply | Search | Statistics | Manual |
Official Addons and Solutions miniBB Support Forums / Official Addons and Solutions /   

Bulleted List BB code

Page  Page 1 of 2:  1  2  Next »  
Author nelson
#1 | Posted: 27 Apr 2009 15:02 
Thanks for minibb, it's really a great product and I have found this site very helpful.

I'm looking to implement bulleted lists in my bbcode ([list]). I would simply like a minor indent and a list similar to that provided by the html
    tag. Been playing with $pattern and $replacement within enCodeBB() and deCodeBB() in my bb_codes.php file, but I'm a novice and can't seem to get it right.

    Has anyone set this up?

Author Paul
Lead Developer
#2 | Posted: 27 Apr 2009 15:37 | Edited by: Paul 
What should be the BB code itself, how do you think? I.e. what should you type as BB code to get such list.

In the final HTML code, this is combination of the two tags - <ul> and <li>. I'm not sure how it's implemented in the other forum software, but I guess for regular users which don't know HTML, it may be difficult to combine those tags properly.

Author tom322
Active Member
#3 | Posted: 27 Apr 2009 15:55 | Edited by: tom322 
I think I've got a simple solution ;). In bb_codes (in enCode function only is enough, I think) put this code:


(in the replacement between the '' enter without spaces: & # 9679;)

and then just enter [list] to create a list circle.

But to be sure, in the deCode function enter:


(replace * with no-spaces: & # 9679;)

Author nelson
#4 | Posted: 27 Apr 2009 21:42 | Edited by: nelson 
Thanks tom322, that is a simple way to do it and it works. Only thing, the formatting is missing.

I am trying to find a way to get [list] and [/list] to perform the function of html's <ul> and </ul>. Then, on other systems I have seen [*] used to indicate the start of each list item. Only problem, that way there is no </li> at the end of each list item. On other systems I have seen [list=1] to turn it into a numbered list - as in html's <ol>.

I appreciate your help guys - haven't gotten it to work just right by myself.

Author Paul
Lead Developer
#5 | Posted: 28 Apr 2009 03:49 
As I mentioned, I would like just to know the BB code format as you type it in :-) then I could work on it.

Tom's solution is just about replacing [list] code by a circle sign, but it's not the "real" list as it could appear in HTML.

My suggestion would be that the format is like this:

list item #1
list item #2
list item #3

So if you type list=A it will be a regular list (<ul>), list=1 would be a numbered list (</ol>), and all items within such tags are separated by newlines. I guess for simple lists there is no need to introduce asterisk or other symbols... in most common cases, list items take no longer than one phrase anyway.


Author nelson
#6 | Posted: 28 Apr 2009 06:33 
Paul that sounds like clean bbcode.

Here is the way I have seen it on other forums, which I was trying to emulate:

[*]list item 1
[*]list item 2
[*]list item 3

But I like your idea, with a new line as the divider between each <li>, there is no need to complicate the bbcode with additional tags.

Author Paul
Lead Developer
#7 | Posted: 28 Apr 2009 08:39 
Ok. Give me couple of days and I'll try to figure my solution out.

Author Paul
Lead Developer
#8 | Posted: 30 Apr 2009 04:47 
Ok, here is the solution you may try to put under bb_codes.php.

Before the function enCodeBB starts declaring, paste the following function:

function encodeList($matches){
$preg=preg_replace("#[\r\n]+#", '
  • ', trim($matches[1]));
    return '
    • '.$preg.'


  • After the line which in encodeBB function says

    $msg=preg_replace($pattern, $replacement, $msg);


    $msg=preg_replace_callback("/\[list\][\r\n]+(.+?)[\r\n]+\[\/list\][\r\n]*/is", 'encodeList', $msg);

    Then modify decodeBB function and before the line

    $msg=preg_replace($pattern, $replacement, $msg);


    /* List BB code */
    $pattern[] = '/
      $replacement[] = "[list]\r\n\\1[/list]\n";

      $pattern[] = '/
    • (.+?)<\/li>/is';
      $replacement[] = "\\1\r\n";

      /* --List BB code */

    In the final I think there is no need to complicate the code with
        tags. The example above works with
          tag. If you need to introduce
            tag as well, just create another function, let's say encodeListA, and put the proper references everywhere, creating just 2 different BB codes.

            Then let me know how it works ;-)

    Author nelson
    #9 | Posted: 30 Apr 2009 12:00 
    Thanks a lot Paul, this works well. Now I can use CSS if I want to play with margins or other formatting.

    Author Paul
    Lead Developer
    #10 | Posted: 30 Apr 2009 13:09 
    It's the same class coming from the main miniBB CSS file.

    Feel free to rename it and create your own, for message only ;-)

    Author tom322
    Active Member
    #11 | Posted: 30 Apr 2009 13:26 
    Hmm, I followed the instructions and tested it on two websites but it didn't work for me.. I assume I should enter:

    [list]some text [/list]

    to make it work, but it didn't.

    nelson - did you follow the exact instructions and it worked without problems?

    Author nelson
    #12 | Posted: 30 Apr 2009 13:34 
    Yes, I modified bb_codes.php as described, and since the bb code is using new lines to determine list items, my post looks like this:

    list item number one
    list item number two

    Author tom322
    Active Member
    #13 | Posted: 30 Apr 2009 13:37 | Edited by: tom322 
    Right.. OK, I got it now -- with my tests I tried something like that below and that's why I didn't get any results: )

    [list]list item number one
    list item number two

    Now only if I knew how to 'force' the paste_strinL so that when I highlight text and click on the button_list.gif button then after the [list] there is automatically inserted a line break and before [/list] there is also a line break.

    I tried something like below (note
    ) but it obviously didn't work ;).

    ,'[/list]','')" onmouseover="window.status='List'; return true" onmouseout="window.status=''; return true" onmousemove="pasteSel()">"List"

    Author Paul
    Lead Developer
    #14 | Posted: 1 May 2009 08:45 | Edited by: Paul 
    tom322: newline in Javascript is \n , not
    , so I suppose the code should be:


    Author tom322
    Active Member
    #15 | Posted: 1 May 2009 10:46 | Edited by: tom322 
    Yes, I also tried \n but I got a javascript error (not that I tried exactly like your code ;).. Now I tried the new code and it works great!

    Page  Page 1 of 2:  1  2  Next » 
    Official Addons and Solutions miniBB Support Forums / Official Addons and Solutions / Bulleted List BB code Top

    Your Reply Click this icon to move up to the quoted message

     Short link for this topic:

    You are welcome to post anonymously, by entering a nickname with no password (if the similar Username has not been taken yet), or by leaving both fields empty. If you have a forums account, you can also sign in from this page without posting a message, or sign in and post at once.

    Before posting, make sure your message is compliant with our forum posting rules. If not, it may be locked or deleted with no explanation.
    miniBB Support Forums Powered by Forum Software miniBB ® Features  Requirements  Demo  Download  Showcase  Gallery of Arts
    Compiler  Premium Extensions  Premium Support  License  Contacts
    Install the Captcha add-on: protect your miniBB-forums from the automated spam and flood.
    Captcha Addon for miniBB