MyBB Community Forums

Full Version: (Ask) How to make a spoiler?
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
ask: how to make a spoiler (open / closed) in MyBB?

This example:[Image: Capture.png]
Go to ACP> Configuration and on the left hand side of the screen click on 'MyCode'

Once in there go to 'Add new code' and enter this into the fields:

Regular expression:
\[spoiler\](.*?)\[/spoiler\]


Replacement:
<div style="margin:20px; margin-top:5px"><div class="quotetitle"><input class="button2 btnlite" type="button" value="View Spoiler" style="text-align:center;width:115px;margin:0px;padding:0px;" onclick="if (this.parentNode.parentNode.getElementsByTagName('div')[1].getElementsByTagName('div')[0].style.display != '') { this.parentNode.parentNode.getElementsByTagName('div')[1].getElementsByTagName('div')[0].style.display = '';      this.innerText = ''; this.value = 'Hide Spoiler'; } else { this.parentNode.parentNode.getElementsByTagName('div')[1].getElementsByTagName('div')[0].style.display = 'none'; this.innerText = ''; this.value = 'View Spoiler'; }" /></div><div class="quotecontent"><div style="display: none;">$1</div></div></div>
(2017-02-14, 08:55 AM)Nemus Wrote: [ -> ]Go to ACP> Configuration and on the left hand side of the screen click on 'MyCode'

Once in there go to 'Add new code' and enter this into the fields:

Regular expression:
\[spoiler\](.*?)\[/spoiler\]


Replacement:
<div style="margin:20px; margin-top:5px"><div class="quotetitle"><input class="button2 btnlite" type="button" value="View Spoiler" style="text-align:center;width:115px;margin:0px;padding:0px;" onclick="if (this.parentNode.parentNode.getElementsByTagName('div')[1].getElementsByTagName('div')[0].style.display != '') { this.parentNode.parentNode.getElementsByTagName('div')[1].getElementsByTagName('div')[0].style.display = '';      this.innerText = ''; this.value = 'Hide Spoiler'; } else { this.parentNode.parentNode.getElementsByTagName('div')[1].getElementsByTagName('div')[0].style.display = 'none'; this.innerText = ''; this.value = 'View Spoiler'; }" /></div><div class="quotecontent"><div style="display: none;">$1</div></div></div>
I've done it like that, but not running

This is the result when I add the code
Looks like you use the [ code ] tag, not [ spoiler ]
I've tried the code, only the result as Tag, I mean spoiler can be opened and closed
You can also try spoiler plugin instead of using Mycode :-
https://community.mybb.com/mods.php?action=view&pid=143

Though Mycode is also okay.

Regards
WallBB
You have used the code tag, not [spoiler] text here [/spoiler]

To use it, you have to use the spoiler code which is:

 [spoiler]ENTER TEXT HERE[/spoiler]
Try this one:

https://community.mybb.com/mods.php?action=view&pid=614

Others have to work too, but this add button to sceditor and stylesheet to customize spoilers.

And finally texts to multilang support, eable three types of spoilers.

So this oe should work i have it into localhost with 1.8.11 and on my site with another lesser version of m ybb but it works in all mybb 1.8.x series of mybb.
Iv'e got this working great but having trouble adding it to the editor bar were the other codes and smiles are. (I'm a pure noob to Mybb)