2016-07-21, 10:04 AM
Hi everyone. I'm just trying to learn how MyBB works, so apologize if my question reveals my utter newbness...
Coming from Zetaboards and running some experiment on Icyboards, I tried to add a very useful piece of template that (on zeta) allowed the user to change their name and picture for a single post (that is to say, if my username is Storyteller, but for a specific post I want it to appear as "Monster of the Week", I can write [alias=Monster of the Week] in my post, and that'll appear in my miniprofile for that single post; similar tag can be used to change avatar in a similar fashion).
So, I took the following script...
... and I added it as a new template (Global Templates --> Add Template). Apparently it wasn't the right thing to do, because it doesn't work... However (see the newb disclaimer above) I cannot tell if it's because the script itself isn't compatible, or if I had to... put it somewhere else?
Can anyone help with this? Or, do any of you know anything that works for the same purpose? (Custom name and pic for single post, without having to create a special accont for all your disposabe NPCs; possibly by the means of simple BCC in post, so that's available to regular members too).
If it's needed for any purpose, the board on which I am is here.
Coming from Zetaboards and running some experiment on Icyboards, I tried to add a very useful piece of template that (on zeta) allowed the user to change their name and picture for a single post (that is to say, if my username is Storyteller, but for a specific post I want it to appear as "Monster of the Week", I can write [alias=Monster of the Week] in my post, and that'll appear in my miniprofile for that single post; similar tag can be used to change avatar in a similar fashion).
So, I took the following script...
script Wrote:<script type="text/javascript">
$('td:contains([AVATAR=):not(:has(textarea))').each(function () {
$(this).html($(this).html().replace(/\[AVATAR=(.+?)\]/gi, '<span class="AI$1"></span>'));
});
$('td:contains([avatar=):not(:has(textarea))').each(function () {
$(this).html($(this).html().replace(/\[avatar=(.+?)\]/gi, '<span class="AI$1"></span>'));
});
$('tr[id*="post-"]').each(function () {
if ($(this).next('tr').find('td.c_post span[class*="AI"]').length) {
var iURL = $(this).next('tr').find('td.c_post span[class*="AI"]').attr('class').split('AI')[1];
$(this).next('tr').find('td.c_user img.avatar, td.c_user img.member').attr('src', iURL);
}
});
$('#avatars select').change(function() {
var iURLN = $(this).val();
if (iURLN === '0') {
$('#avatars img').show().attr('src', '');
$('#c_post-text').val($('#c_post-text').val().replace(/ \[ALIAS=(.+?)\]/gi, ''));
} else {
$('#avatars img').show().attr('src', iURLN);
$('#c_post-text').val($('#c_post-text').val().replace(/ \[ALIAS=(.+?)\]/gi, ''));
$('#c_post-text').val($('#c_post-text').val() + ' [ALIAS=' + iURLN + ']');
}
});
$('td:contains([ALIAS=):not(:has(textarea))').each(function() {
$(this).html($(this).html().replace(/\[ALIAS=(.+?)\]/gi, '<span class="UN$1"></span>'));
});
$('#avatars select').change(function() {
var iURLN = $(this).val();
if (iURLN === '0') {
$('#avatars img').show().attr('src', '');
$('#c_post-text').val($('#c_post-text').val().replace(/ \[alias=(.+?)\]/gi, ''));
} else {
$('#avatars img').show().attr('src', iURLN);
$('#c_post-text').val($('#c_post-text').val().replace(/ \[alias=(.+?)\]/gi, ''));
$('#c_post-text').val($('#c_post-text').val() + ' [alias=' + iURLN + ']');
}
});
$('td:contains([alias=):not(:has(textarea))').each(function() {
$(this).html($(this).html().replace(/\[alias=(.+?)\]/gi, '<span class="UN$1"></span>'));
});
$('tr[id*="post-"]').each(function() {
if ($(this).next('tr').find('td.c_post span[class*="UN"]').length) {
var iURLN = $(this).next('tr').find('td.c_post span[class*="UN"]').attr('class').split('UN')[1];
$(this).find('td.c_username a:eq(0)').text(iURLN);
}
});
</script>
... and I added it as a new template (Global Templates --> Add Template). Apparently it wasn't the right thing to do, because it doesn't work... However (see the newb disclaimer above) I cannot tell if it's because the script itself isn't compatible, or if I had to... put it somewhere else?
Can anyone help with this? Or, do any of you know anything that works for the same purpose? (Custom name and pic for single post, without having to create a special accont for all your disposabe NPCs; possibly by the means of simple BCC in post, so that's available to regular members too).
If it's needed for any purpose, the board on which I am is here.