miniBB ® 

miniBB

®
Support Forums
  
 | Start | Register | Search | Statistics | File Bank | 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
Partaker
#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 <ul> 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 
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 
I think I've got a simple solution ;). In bb_codes (in enCode function only is enough, I think) put this code:

$pattern[]="/\[list\]/is";
$replacement[]='';

(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:

$pattern[]="/*/is";
$replacement[]="[list]";

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

Author nelson
Partaker
#4 | Posted: 27 Apr 2009 21:42 
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 
nelson
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=A|1]
list item #1
list item #2
list item #3
[/list]

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.

Thoughts?..

Author nelson
Partaker
#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=A|1]
[*]list item 1
[*]list item 2
[*]list item 3
[/list]

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]
+#", '</li><li>', trim($matches[1]));
return '<ul class="limbb"><li>'.$preg.'</li></ul><br />';
}
After the line which in encodeBB function says


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


paste:

$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);


paste:

/* List BB code */
$pattern[] = '/<ul class="limbb">(.+?)<\/ul>/is';
$replacement[] = "[list]\r\n\\1[/list]\n";

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

/* --List BB code */
In the final I think there is no need to complicate the code with <ul>/<ol> tags. The example above works with <ul> tag. If you need to introduce <ol> 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
Partaker
#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
Partaker
#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]
list item number one
list item number two
[/list]

Author tom322
Active Member
#13 | Posted: 30 Apr 2009 13:37 
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
[/list]

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 <br />) but it obviously didn't work ;).

<a href="JavaScript:paste_strinL(selektion,3,'[list]'+<br />,'[/list]','')" onmouseover="window.status='List'; return true" onmouseout="window.status=''; return true" onmousemove="pasteSel()"><img src="https://www.minibb.com/forums/img/button_list.gif" alt="List" title="List" style="width:23px;height:22px"/></a>

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

<a href="JavaScript:paste_strinL(selektion,3,'[list]\n','\n[/list]','')" onmouseover="window.status='List'; return true" onmouseout="window.status=''; return true" onmousemove="pasteSel()"><img src="https://www.minibb.com/forums/img/button_list.gif" alt="List" title="List" style="width:23px;height:22px"/></a>

Author tom322
Active Member
#15 | Posted: 1 May 2009 10:46 
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
 Share Topic's Link

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


  ?
Post as a Guest, leaving the Password field blank. You could also enter a Guest name, if it's not taken by a member yet. Sign-in and post at once, or just sign-in, bypassing the message's text.


Before posting, make sure your message is compliant with forum rules; otherwise it could be locked or removed with no explanation.

 

 
 
miniBB Support Forums Powered by Forum Software miniBB ® Home  Features  Requirements  Demo  Download  Showcase  Gallery of Arts
Compiler  Premium Extensions  Premium Support  License  Contact Us
Proceed with the Captcha add-on: protect your miniBB-forums from the automated spam and flood.


  ⇑