How to add bbcode?
5 posters
Page 1 of 1
How to add bbcode?
Hello!
I've a few problems and questions. So let me describe them.
1. It is possible to add my own bbcode?
2. If yes, so, what I can edit/add them? To be honest I really want to implement something like hide, but not like this which is "basic" on forumotion. I search for option which allowing create "hide", but not as "comment and see". Just for example,
PS. If this category is wrong, sorry. Im newbie.
I've a few problems and questions. So let me describe them.
1. It is possible to add my own bbcode?
2. If yes, so, what I can edit/add them? To be honest I really want to implement something like hide, but not like this which is "basic" on forumotion. I search for option which allowing create "hide", but not as "comment and see". Just for example,
- Code:
[Hide=USERNICK][/HIDE]
PS. If this category is wrong, sorry. Im newbie.
Re: How to add bbcode?
Hello.
So let me ask this just so I'm on the correct page of what you are trying to implement. You want to use a BBcode to where you can hide content within the brackets to all users except the user indicated in the BBcode?
So let me ask this just so I'm on the correct page of what you are trying to implement. You want to use a BBcode to where you can hide content within the brackets to all users except the user indicated in the BBcode?
Re: How to add bbcode?
I'll just explain this by imageDraxion wrote:Hello.
So let me ask this just so I'm on the correct page of what you are trying to implement. You want to use a BBcode to where you can hide content within the brackets to all users except the user indicated in the BBcode?
We've there a lot of icons represents bbcode. And this what I want is add option for code. Of course if it possible to add bbcode that I mention in topic. And this is the most important thing.
To answer your question - yes, exactly.
Re: How to add bbcode?
First read the following topic: https://help.forumotion.com/t153342-tutorial-create-new-bbcode-tags?highlight=bbcode
After reading the topic and understanding how it works. Create a new JavaScript file and add:
(Placement: All Pages)
To use the BBCode, use the following tags: [onlyto="USERNAMEHERE"]YOUR CONTENT TO SHOW HERE[/onlyto]
After reading the topic and understanding how it works. Create a new JavaScript file and add:
(Placement: All Pages)
- Code:
/*
* Application: Create New BBCode Tags
* Date: 18/05/2018
* Version: 1.321052018
* Copyright (c) 2018 Daemon <help.forumotion.com>
* This work is free. You can redistribute it and/or modify it
*/
(function() {
BBParser = {
initialize: function() {
$(function() {
BBParser.setupBBParser();
});
},
add: [
/*
* Note: Add a comma at the end of each new entry
* '{option}' corresponds to the optional tag title, and '{content}' correspond to the text between the tags
*/
{
tag: 'success',
close: true,
replacement: '<div class="notice notice-success"><h5>{option}</h5><p>{content}</p></div>'
},
{
tag: 'warn',
close: true,
replacement: '<div class="notice notice-warn"><h5>{option}</h5><p>{content}</p></div>'
},
{
tag: 'info',
close: true,
replacement: '<div class="notice notice-info"><h5>{option}</h5><p>{content}</p></div>'
},
{
tag: 'alert',
close: true,
replacement: '<div class="notice notice-alert"><h5>{option}</h5><p>{content}</p></div>'
},
{
tag: 'onlyto',
close: true,
replacement: '<div class="onlyto">{content}</div>',
replace: function(option, content) {
if (_userdata.username != option) {
return 'Only ' + option + ' can view this message.';
return content;
}
}
},
// Note: Do not add a comma at the end of the last entry
],
// Do not change anything down
validateTag: function(a) {
if (!/^\w+$/.test(a)) throw new RangeError("You added an invalid tag: " + a);
},
replacers: function(a, b, c) {
return (a || "").replace(/{option}/g, b || "").replace(/{content}/g, c || "");
},
optionReg: /.*?=("|'|)(.*?)\1\]/,
parsedContent: function(a, b, c) {
return a.replace(c ? RegExp("(\\[" + b.tag + "[^\\]]*\\])([\\s\\S]*?)\\[/" + b.tag + "]", "g" + (b.insensitive ? "i" : "")) : RegExp("\\[" + b.tag + "[^\\]]*\\]", "g" + (b.insensitive ? "i" : "")), function(d, e, f) {
c || (e = d);
e = BBParser.optionReg.test(e) ? e.replace(BBParser.optionReg, "$2") : b.defaultOption;
if("undefined" !== typeof b.replace) {
d = c ? b.replace(e, f) : b.replace(e);
"string" === typeof d ? c ? f = d : e = d : d;
"object" === typeof d && (e = d.option || e, f = d.content || f);
}
return BBParser.replacers(b.replacement, e, f);
});
},
setupBBParser: function() {
var postBody = $(".postbody, .blog_message");
for (var i = 0, e;(e = postBody[i++]);) {
for (var j in BBParser.add) {
var item = BBParser.add[j];
// Validating tag
BBParser.validateTag(item.tag);
e.innerHTML = BBParser.parsedContent(e.innerHTML, item, item.close);
}
}
}
};
BBParser.initialize()
})();
To use the BBCode, use the following tags: [onlyto="USERNAMEHERE"]YOUR CONTENT TO SHOW HERE[/onlyto]
Daemon- Forumember
- Posts : 104
Reputation : 91
Language : Português
Re: How to add bbcode?
Daemon wrote:First read the following topic: https://help.forumotion.com/t153342-tutorial-create-new-bbcode-tags?highlight=bbcode
After reading the topic and understanding how it works. Create a new JavaScript file and add:
(Placement: All Pages)
- Code:
/*
* Application: Create New BBCode Tags
* Date: 18/05/2018
* Version: 1.321052018
* Copyright (c) 2018 Daemon <help.forumotion.com>
* This work is free. You can redistribute it and/or modify it
*/
(function() {
BBParser = {
initialize: function() {
$(function() {
BBParser.setupBBParser();
});
},
add: [
/*
* Note: Add a comma at the end of each new entry
* '{option}' corresponds to the optional tag title, and '{content}' correspond to the text between the tags
*/
{
tag: 'success',
close: true,
replacement: '<div class="notice notice-success"><h5>{option}</h5><p>{content}</p></div>'
},
{
tag: 'warn',
close: true,
replacement: '<div class="notice notice-warn"><h5>{option}</h5><p>{content}</p></div>'
},
{
tag: 'info',
close: true,
replacement: '<div class="notice notice-info"><h5>{option}</h5><p>{content}</p></div>'
},
{
tag: 'alert',
close: true,
replacement: '<div class="notice notice-alert"><h5>{option}</h5><p>{content}</p></div>'
},
{
tag: 'onlyto',
close: true,
replacement: '<div class="onlyto">{content}</div>',
replace: function(option, content) {
if (_userdata.username != option) {
return 'Only ' + option + ' can view this message.';
return content;
}
}
},
// Note: Do not add a comma at the end of the last entry
],
// Do not change anything down
validateTag: function(a) {
if (!/^\w+$/.test(a)) throw new RangeError("You added an invalid tag: " + a);
},
replacers: function(a, b, c) {
return (a || "").replace(/{option}/g, b || "").replace(/{content}/g, c || "");
},
optionReg: /.*?=("|'|)(.*?)\1\]/,
parsedContent: function(a, b, c) {
return a.replace(c ? RegExp("(\\[" + b.tag + "[^\\]]*\\])([\\s\\S]*?)\\[/" + b.tag + "]", "g" + (b.insensitive ? "i" : "")) : RegExp("\\[" + b.tag + "[^\\]]*\\]", "g" + (b.insensitive ? "i" : "")), function(d, e, f) {
c || (e = d);
e = BBParser.optionReg.test(e) ? e.replace(BBParser.optionReg, "$2") : b.defaultOption;
if("undefined" !== typeof b.replace) {
d = c ? b.replace(e, f) : b.replace(e);
"string" === typeof d ? c ? f = d : e = d : d;
"object" === typeof d && (e = d.option || e, f = d.content || f);
}
return BBParser.replacers(b.replacement, e, f);
});
},
setupBBParser: function() {
var postBody = $(".postbody, .blog_message");
for (var i = 0, e;(e = postBody[i++]);) {
for (var j in BBParser.add) {
var item = BBParser.add[j];
// Validating tag
BBParser.validateTag(item.tag);
e.innerHTML = BBParser.parsedContent(e.innerHTML, item, item.close);
}
}
}
};
BBParser.initialize()
})();
To use the BBCode, use the following tags: [onlyto="USERNAMEHERE"]YOUR CONTENT TO SHOW HERE[/onlyto]
Wow, it really works. Really thank you. Next question, of course this version is good for me but could be better (sorry, i don't mentioned about this in my last post). It is possible to in this "hide" do something like: only this "NICKNAMEUSER" see content + administrator? Whether solely option is to type their nicknames?
Re: How to add bbcode?
I forgot to mention that this script allows you to create other BBCode tags. If you read the topic I sent, you will see some BBCode options.
By default, 4 BBCodes are already added. test the tags:
And to allow administrators to see the content as well, change your code by this:
By default, 4 BBCodes are already added. test the tags:
- Code:
[success="OPTIONAL"]Content goes here[/success]
[warn="OPTIONAL"]Content goes here[/warn]
[alert="OPTIONAL"]Content goes here[/alert]
[info="OPTIONAL"]Content goes here[/info]
And to allow administrators to see the content as well, change your code by this:
- Code:
/*
* Application: Create New BBCode Tags
* Date: 18/05/2018
* Version: 1.321052018
* Copyright (c) 2018 Daemon <help.forumotion.com>
* This work is free. You can redistribute it and/or modify it
*/
(function() {
BBParser = {
initialize: function() {
$(function() {
BBParser.setupBBParser();
});
},
add: [
/*
* Note: Add a comma at the end of each new entry
* '{option}' corresponds to the optional tag title, and '{content}' correspond to the text between the tags
*/
{
tag: 'success',
close: true,
replacement: '<div class="notice notice-success"><h5>{option}</h5><p>{content}</p></div>'
},
{
tag: 'warn',
close: true,
replacement: '<div class="notice notice-warn"><h5>{option}</h5><p>{content}</p></div>'
},
{
tag: 'info',
close: true,
replacement: '<div class="notice notice-info"><h5>{option}</h5><p>{content}</p></div>'
},
{
tag: 'alert',
close: true,
replacement: '<div class="notice notice-alert"><h5>{option}</h5><p>{content}</p></div>'
},
{
tag: 'onlyto',
close: true,
replacement: '<div class="onlyto">{content}</div>',
replace: function(option, content) {
if (_userdata.username != option && _userdata.user_level != 1) {
return 'Only ' + option + ' can view this message.';
return content;
}
}
},
// Note: Do not add a comma at the end of the last entry
],
// Do not change anything down
validateTag: function(a) {
if (!/^\w+$/.test(a)) throw new RangeError("You added an invalid tag: " + a);
},
replacers: function(a, b, c) {
return (a || "").replace(/{option}/g, b || "").replace(/{content}/g, c || "");
},
optionReg: /.*?=("|'|)(.*?)\1\]/,
parsedContent: function(a, b, c) {
return a.replace(c ? RegExp("(\\[" + b.tag + "[^\\]]*\\])([\\s\\S]*?)\\[/" + b.tag + "]", "g" + (b.insensitive ? "i" : "")) : RegExp("\\[" + b.tag + "[^\\]]*\\]", "g" + (b.insensitive ? "i" : "")), function(d, e, f) {
c || (e = d);
e = BBParser.optionReg.test(e) ? e.replace(BBParser.optionReg, "$2") : b.defaultOption;
if("undefined" !== typeof b.replace) {
d = c ? b.replace(e, f) : b.replace(e);
"string" === typeof d ? c ? f = d : e = d : d;
"object" === typeof d && (e = d.option || e, f = d.content || f);
}
return BBParser.replacers(b.replacement, e, f);
});
},
setupBBParser: function() {
var postBody = $(".postbody, .blog_message");
for (var i = 0, e;(e = postBody[i++]);) {
for (var j in BBParser.add) {
var item = BBParser.add[j];
// Validating tag
BBParser.validateTag(item.tag);
e.innerHTML = BBParser.parsedContent(e.innerHTML, item, item.close);
}
}
}
};
BBParser.initialize()
})();
Daemon- Forumember
- Posts : 104
Reputation : 91
Language : Português
Re: How to add bbcode?
Remember to read my last message above.
If you want more than one user to view the content, replace the code with this:
Now you can do this:
If you want more than one user to view the content, replace the code with this:
- Code:
/*
* Application: Create New BBCode Tags
* Date: 18/05/2018
* Version: 1.321052018
* Copyright (c) 2018 Daemon <help.forumotion.com>
* This work is free. You can redistribute it and/or modify it
*/
(function() {
BBParser = {
initialize: function() {
$(function() {
BBParser.setupBBParser();
});
},
add: [
/*
* Note: Add a comma at the end of each new entry
* '{option}' corresponds to the optional tag title, and '{content}' correspond to the text between the tags
*/
{
tag: 'success',
close: true,
replacement: '<div class="notice notice-success"><h5>{option}</h5><p>{content}</p></div>'
},
{
tag: 'warn',
close: true,
replacement: '<div class="notice notice-warn"><h5>{option}</h5><p>{content}</p></div>'
},
{
tag: 'info',
close: true,
replacement: '<div class="notice notice-info"><h5>{option}</h5><p>{content}</p></div>'
},
{
tag: 'alert',
close: true,
replacement: '<div class="notice notice-alert"><h5>{option}</h5><p>{content}</p></div>'
},
{
tag: 'onlyto',
close: true,
replacement: '<div class="onlyto">{content}</div>',
replace: function(option, content) {
var myArray = new Array();
// this will return an array with strings "1", "2", etc.
myArray = option.split(",").map(function(el) {
return el.trim();
});
if ($.inArray(_userdata.username, myArray) == -1 && _userdata.user_level != 1) {
return 'Only ' + myArray.join(", ").replace(/,([^,]*)$/, ' and $1') + ' can view this message';
return content;
}
}
}
// Note: Do not add a comma at the end of the last entry
],
// Do not change anything down
validateTag: function(a) {
if (!/^\w+$/.test(a)) throw new RangeError("You added an invalid tag: " + a);
},
replacers: function(a, b, c) {
return (a || "").replace(/{option}/g, b || "").replace(/{content}/g, c || "");
},
optionReg: /.*?=("|'|)(.*?)\1\]/,
parsedContent: function(a, b, c) {
return a.replace(c ? RegExp("(\\[" + b.tag + "[^\\]]*\\])([\\s\\S]*?)\\[/" + b.tag + "]", "g" + (b.insensitive ? "i" : "")) : RegExp("\\[" + b.tag + "[^\\]]*\\]", "g" + (b.insensitive ? "i" : "")), function(d, e, f) {
c || (e = d);
e = BBParser.optionReg.test(e) ? e.replace(BBParser.optionReg, "$2") : b.defaultOption;
if("undefined" !== typeof b.replace) {
d = c ? b.replace(e, f) : b.replace(e);
"string" === typeof d ? c ? f = d : e = d : d;
"object" === typeof d && (e = d.option || e, f = d.content || f);
}
return BBParser.replacers(b.replacement, e, f);
});
},
setupBBParser: function() {
var postBody = $(".postbody, .blog_message");
for (var i = 0, e;(e = postBody[i++]);) {
for (var j in BBParser.add) {
var item = BBParser.add[j];
// Validating tag
BBParser.validateTag(item.tag);
e.innerHTML = BBParser.parsedContent(e.innerHTML, item, item.close);
}
}
}
};
BBParser.initialize()
})();
Now you can do this:
- Code:
[onlyto="USERNAME1, USERNAME2, USERNAME5"]Content[/onlyto]
Daemon- Forumember
- Posts : 104
Reputation : 91
Language : Português
Re: How to add bbcode?
Remember to mark your topic when a solution is found.
General Rules | Tips & Tricks | FAQ | Forgot Founder Password?
Team Leader
Review Section Rules | Request A Review | Sticker Points
Re: How to add bbcode?
Problem solved & topic archived.
|
Lost Founder's Password |Forum's Utilities |Report a Forum |General Rules |FAQ |Tricks & Tips
You need one post to send a PM.
You need one post to send a PM.
When your topic has been solved, ensure you mark the topic solved.
Never post your email in public.
Similar topics
» How can add the BBCode Button on the title bar of BBCode Table?
» BBcode
» bbcode
» BBCode for multi-tab
» Alternative for bbcode
» BBcode
» bbcode
» BBCode for multi-tab
» Alternative for bbcode
Page 1 of 1
Permissions in this forum:
You cannot reply to topics in this forum