The forum of the forums
Would you like to react to this message? Create an account in a few clicks or log in to continue.

Create bb codes

5 posters

Go down

Create bb codes Empty Create bb codes

Post by Destro05 June 12th 2013, 2:11 pm

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.
avatar
Destro05
New Member

Posts : 4
Reputation : 1
Language : Greek

Back to top Go down

Create bb codes Empty Re: Create bb codes

Post by Ultron's Vision June 12th 2013, 2:22 pm

A forumotion-internal solution is not existing though you can use JavaScript.

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>');
Ultron's Vision
Ultron's Vision
Forumember

Male Posts : 634
Reputation : 45
Language : English | German | HTML | JavaScript | PHP | C++ | Perl | Java
Location : Vienna, Austria

http://duelacademy.net

Back to top Go down

Create bb codes Empty Re: Create bb codes

Post by Destro05 June 12th 2013, 2:23 pm

Ty! solved
avatar
Destro05
New Member

Posts : 4
Reputation : 1
Language : Greek

Back to top Go down

Create bb codes Empty Re: Create bb codes

Post by Ultron's Vision June 12th 2013, 2:26 pm

Did it work? Wink

Mark this as solved if it did to simplify the moderators' jobs Smile
Ultron's Vision
Ultron's Vision
Forumember

Male Posts : 634
Reputation : 45
Language : English | German | HTML | JavaScript | PHP | C++ | Perl | Java
Location : Vienna, Austria

http://duelacademy.net

Back to top Go down

Create bb codes Empty Re: Create bb codes

Post by Destro05 June 12th 2013, 2:40 pm

It doesn't Sad

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.
avatar
Destro05
New Member

Posts : 4
Reputation : 1
Language : Greek

Back to top Go down

Create bb codes Empty Re: Create bb codes

Post by LGforum June 12th 2013, 2:55 pm

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
LGforum
LGforum
Hyperactive

Male Posts : 2265
Reputation : 264
Language : English
Location : UK

Back to top Go down

Create bb codes Empty Re: Create bb codes

Post by Ultron's Vision June 12th 2013, 2:57 pm

Hm, right, I thought they did.

Well, nice to see that someone else already took care of it. Thank you LG!
Ultron's Vision
Ultron's Vision
Forumember

Male Posts : 634
Reputation : 45
Language : English | German | HTML | JavaScript | PHP | C++ | Perl | Java
Location : Vienna, Austria

http://duelacademy.net

Back to top Go down

Create bb codes Empty Re: Create bb codes

Post by Destro05 June 12th 2013, 3:09 pm

I'll try your way and i reply there...Thanks!
avatar
Destro05
New Member

Posts : 4
Reputation : 1
Language : Greek

Back to top Go down

Create bb codes Empty Re: Create bb codes

Post by LGforum June 12th 2013, 3:10 pm

As I say you were on the right lines. In it's simplest form, you were likely thinking of this:
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
LGforum
Hyperactive

Male Posts : 2265
Reputation : 264
Language : English
Location : UK

Back to top Go down

Create bb codes Empty Re: Create bb codes

Post by Ultron's Vision June 12th 2013, 3:17 pm

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 :/
Ultron's Vision
Ultron's Vision
Forumember

Male Posts : 634
Reputation : 45
Language : English | German | HTML | JavaScript | PHP | C++ | Perl | Java
Location : Vienna, Austria

http://duelacademy.net

Back to top Go down

Create bb codes Empty Re: Create bb codes

Post by Mr.EasyBB June 12th 2013, 4:23 pm

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>" });
avatar
Mr.EasyBB
Forumember

Posts : 71
Reputation : 9
Language : HTML/CSS/JS/JQUERY/MOOTOOLS

http://www.avacweb.com

Back to top Go down

Create bb codes Empty Re: Create bb codes

Post by LGforum June 12th 2013, 4:27 pm

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.
LGforum
LGforum
Hyperactive

Male Posts : 2265
Reputation : 264
Language : English
Location : UK

Back to top Go down

Create bb codes Empty Re: Create bb codes

Post by Mr.EasyBB June 12th 2013, 4:30 pm

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!
avatar
Mr.EasyBB
Forumember

Posts : 71
Reputation : 9
Language : HTML/CSS/JS/JQUERY/MOOTOOLS

http://www.avacweb.com

Back to top Go down

Create bb codes Empty Re: Create bb codes

Post by mangaka June 13th 2013, 3:39 pm

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
mangaka
Forumember

Female Posts : 121
Reputation : 5
Language : Indonesia
Location : Well

Back to top Go down

Back to top


 
Permissions in this forum:
You cannot reply to topics in this forum