The forum of the forums
Welcome to the Official Support Forum of Forumotion!

To take full advantage of everything offered by our forum, please log in if you are already a member, or join our community if you've not yet.



Create a free forum like this one.

Create bb codes

View previous topic View next topic Go down

Create bb codes

Post by Destro05 on June 12th 2013, 1: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.

Destro05
New Member

Posts : 4
Reputation : 1
Language : Greek

Back to top Go down

Re: Create bb codes

Post by Ultron's Vision on June 12th 2013, 1: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
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

Re: Create bb codes

Post by Destro05 on June 12th 2013, 1:23 pm

Ty! solved

Destro05
New Member

Posts : 4
Reputation : 1
Language : Greek

Back to top Go down

Re: Create bb codes

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

Did it work? Wink

Mark this as solved if it did to simplify the moderators' jobs Smile

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

Re: Create bb codes

Post by Destro05 on June 12th 2013, 1: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.

Destro05
New Member

Posts : 4
Reputation : 1
Language : Greek

Back to top Go down

Re: Create bb codes

Post by LGforum on June 12th 2013, 1: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
Hyperactive

Male Posts : 2260
Reputation : 258
Language : English
Location : UK

http://www.avacweb.com/

Back to top Go down

Re: Create bb codes

Post by Ultron's Vision on June 12th 2013, 1: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
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

Re: Create bb codes

Post by Destro05 on June 12th 2013, 2:09 pm

I'll try your way and i reply there...Thanks!

Destro05
New Member

Posts : 4
Reputation : 1
Language : Greek

Back to top Go down

Re: Create bb codes

Post by LGforum on June 12th 2013, 2: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
Hyperactive

Male Posts : 2260
Reputation : 258
Language : English
Location : UK

http://www.avacweb.com/

Back to top Go down

Re: Create bb codes

Post by Ultron's Vision on June 12th 2013, 2: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
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

Re: Create bb codes

Post by Mr.EasyBB on June 12th 2013, 3: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>" });

Mr.EasyBB
Forumember

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

http://www.avacweb.com

Back to top Go down

Re: Create bb codes

Post by LGforum on June 12th 2013, 3: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
Hyperactive

Male Posts : 2260
Reputation : 258
Language : English
Location : UK

http://www.avacweb.com/

Back to top Go down

Re: Create bb codes

Post by Mr.EasyBB on June 12th 2013, 3: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!

Mr.EasyBB
Forumember

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

http://www.avacweb.com

Back to top Go down

Re: Create bb codes

Post by mangaka on June 13th 2013, 2: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
Forumember

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

Back to top Go down

View previous topic View next topic Back to top


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