Create bb codes
5 posters
Page 1 of 1
Create bb codes
Hi there!
I would like to know how to create a new bb code.
For example i write [123]hello[/123] and the contain of this, i want to be bold, italic, blue color and size 14.
It's that possible to do?
ps Sorry for bad english.
I would like to know how to create a new bb code.
For example i write [123]hello[/123] and the contain of this, i want to be bold, italic, blue color and size 14.
It's that possible to do?
ps Sorry for bad english.
Destro05- New Member
- Posts : 4
Reputation : 1
Language : Greek
Re: Create bb codes
A forumotion-internal solution is not existing though you can use JavaScript.
Example code would be...
Example code would be...
- Code:
var regex = /\[123\]/g;
regex.replace('<span style="font-size: 14px; font-weight: bold; font-style: italic; text-decoration: underline;">');
var regex2 = /\[\/123\]/g;
regex2.replace('</span>');
Re: Create bb codes
It doesn't
A step to step guide might work.
I go to
Add a Javascript Code and i put the code that you gave but when i go to the forum and i try [123]hello[/123] nothing happened, remains the same simple writting.
A step to step guide might work.
I go to
Add a Javascript Code and i put the code that you gave but when i go to the forum and i try [123]hello[/123] nothing happened, remains the same simple writting.
Destro05- New Member
- Posts : 4
Reputation : 1
Language : Greek
Re: Create bb codes
It doesn't work because Regular Expressions do not have a 'replace' function. Strings do... in which you can use regular expressions.
Ultron is along the right lines and has the right idea but there's a bit more to it than that. Which is why I wrote LGBB so you don't have to. LGBB provides an easy way for adding new BBcodes: http://www.avacweb.com/t428-13-create-new-bbcodes-with-new-lgbb
Ultron is along the right lines and has the right idea but there's a bit more to it than that. Which is why I wrote LGBB so you don't have to. LGBB provides an easy way for adding new BBcodes: http://www.avacweb.com/t428-13-create-new-bbcodes-with-new-lgbb
LGforum- Hyperactive
- Posts : 2265
Reputation : 264
Language : English
Location : UK
Re: Create bb codes
Hm, right, I thought they did.
Well, nice to see that someone else already took care of it. Thank you LG!
Well, nice to see that someone else already took care of it. Thank you LG!
Re: Create bb codes
I'll try your way and i reply there...Thanks!
Destro05- New Member
- Posts : 4
Reputation : 1
Language : Greek
Re: Create bb codes
As I say you were on the right lines. In it's simplest form, you were likely thinking of this:
There comes the problem of invalid HTML and incorrect parsing though. Such as if that code was in place, and I put 'bla bla bla [/bbcode]' into a post. The [/bbcode] would be replace with '</div>', however there is no opening DIV tag, and so that div tag would close another DIV early and mess up the page from there on in. Same with only putting an opening tag.
So there's the issue of only parsing when two tags exist, when the right amount of tags exist, when each tag is closed and opened correctly, and for potentially multiple types of tags. Which is what LGBB takes care of plus a few extra features such as having attributes on the BBcode and being able to replace content.
Hope that's explained things a little better.
- Code:
PieceOfText.replace(/\[bbcode]/g, '<div class="bbcode">').replace(/\[\/bbcode]/g, '</div>');
There comes the problem of invalid HTML and incorrect parsing though. Such as if that code was in place, and I put 'bla bla bla [/bbcode]' into a post. The [/bbcode] would be replace with '</div>', however there is no opening DIV tag, and so that div tag would close another DIV early and mess up the page from there on in. Same with only putting an opening tag.
So there's the issue of only parsing when two tags exist, when the right amount of tags exist, when each tag is closed and opened correctly, and for potentially multiple types of tags. Which is what LGBB takes care of plus a few extra features such as having attributes on the BBcode and being able to replace content.
Hope that's explained things a little better.
LGforum- Hyperactive
- Posts : 2265
Reputation : 264
Language : English
Location : UK
Re: Create bb codes
Oh, I understand perfectly fine, I was probably just mixing up the methods of regexes and strings.
I was originally going to implement type checking (assuming that there was a .replace() method for regexes) and such, but I was in quite a hurry
I was originally going to implement type checking (assuming that there was a .replace() method for regexes) and such, but I was in quite a hurry
Re: Create bb codes
The new editor JS allows for bbcode adding.
- Code:
$.sceditor.plugins.bbcode.bbcode.set("h1", { tags: { h1: null }, format: "[h1]{0}[/h1]", html: "<h1>{0}</h1>" });
Re: Create bb codes
It won't be parsed in posts though. Only on the editor.
When the posts are displayed they are parsed server side, not by the editor, so while that may add a button and make it usable in the WYSIWYG, it won't actually make it work in the posts unfortunately... or at least it shouldn't. If it does, then Forumotion have done a lot more than add a new editor, and to that kudos to them.
When the posts are displayed they are parsed server side, not by the editor, so while that may add a button and make it usable in the WYSIWYG, it won't actually make it work in the posts unfortunately... or at least it shouldn't. If it does, then Forumotion have done a lot more than add a new editor, and to that kudos to them.
LGforum- Hyperactive
- Posts : 2265
Reputation : 264
Language : English
Location : UK
Re: Create bb codes
Lol. I'm actually not liking this editor as I had a custom Image Uploader, and Custom Size Changer, and so much more custom. My editor was 500 times better than this one, and it destroyed my coding because of this editor
Not sure If I can post this, but I already have three tutorials for the new Editor!
Not sure If I can post this, but I already have three tutorials for the new Editor!
Re: Create bb codes
I know how to add some new bbcode for forums in indonesian forum,yes,i know if they was appeared at my bbcode options,but when i type it,i have a same problem.I already inserted the effect for that bbcode,but the effect not worked!!Are you have some oppinion for us!?
mangaka- Forumember
- Posts : 121
Reputation : 5
Language : Indonesia
Location : Well
Page 1 of 1
Permissions in this forum:
You cannot reply to topics in this forum