MyBB Community Forums

Full Version: No spoilers seem to work?
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2 3 4
Ok, I made a mycode spoiler and it worked in the MYCODE sandbox. I disabled all plugins and ran on the clean default templates, no changes.

The spoiler will not open.

Any ideas?
This is the code from Spoiler BBcode plugin:
http://mods.mybb.com/view/spoiler-bbcode

I DONT TAKE ANY CREDITS FOR THIS just linking it.

<?php
$plugins->add_hook("parse_message", "spoiler_run");
function spoiler_info()
{
	return array(
		"name"		=> "Spoiler BBCode",
		"description"	=> "Hides text specified in the [spoiler] tag.",
		"website"		=> "http://www.sephiroth.ws",
		"author"		=> "Sephiroth",
		"authorsite"	=> "http://www.sephiroth.ws",
		"version"		=> "1.6",
		"guid"		=> "795e4538050784720a1196a8b6e8065f",
		"compatibility" => "16*"
	);
}
function spoiler_activate()
{
}
function spoiler_deactivate()
{
}
function spoiler_run($message)
{
	// Assign pattern and replace values.
	$pattern = array("#\[spoiler=(?:&quot;|\"|')?(.*?)[\"']?(?:&quot;|\"|')?\](.*?)\[\/spoiler\](\r\n?|\n?)#si", "#\[spoiler\](.*?)\[\/spoiler\](\r\n?|\n?)#si");

	$replace = array("<div><div class=\"spoiler_header\">$1 <a href=\"javascript:void(0);\" onclick=\"javascript:if(parentNode.parentNode.getElementsByTagName('div')[1].style.display=='block'){parentNode.parentNode.getElementsByTagName('div')[1].style.display='none';this.innerHTML='(Click to View)';}else {parentNode.parentNode.getElementsByTagName('div')[1].style.display='block';this.innerHTML='(Click to Hide)';}\">(Click to View)</a></div><div class=\"spoiler_body\" style=\"display: none;\">$2</div></div>", "<div><div class=\"spoiler_header\">Spoiler <a href=\"javascript:void(0);\" onclick=\"javascript:if(parentNode.parentNode.getElementsByTagName('div')[1].style.display=='block'){parentNode.parentNode.getElementsByTagName('div')[1].style.display='none';this.innerHTML='(Click to View)';}else {parentNode.parentNode.getElementsByTagName('div')[1].style.display='block';this.innerHTML='(Click to Hide)';}\">(Click to View)</a></div><div class=\"spoiler_body\" style=\"display: none;\">$1</div></div>");

	while(preg_match($pattern[0], $message) or preg_match($pattern[1], $message))
	{
		$message = preg_replace($pattern, $replace, $message);
	}
	$find = array(
		"#<div class=\"spoiler_body\">(\r\n?|\n?)#",
		"#(\r\n?|\n?)</div>#"
	);

	$replace = array(
		"<div class=\"spoiler_body\">",
		"</div>"
	);
	$message = preg_replace($find, $replace, $message);
	return $message;
}
?>

And for me this works perfectly, the only issue i have with it is that the image resizer doesnt run in this for some reason.
Hi Anori - I have this one - it ALSO does not open. It is the one I started with.

I am perplexed. You are on 1.6.7?
Yes i am on 1.6.7, and i really have no issues. Maybe it breaks with some other plugin? Since i dont have the issue these are the plugins i use:
  • Wow data links
  • Fit on Page (this one doesnt work within a spoiler tag though but it never did)
  • Form Manager
  • My shoutbox
  • PHP and Template Conditions
  • PM conversation
  • Spoiler BB-code
Run a validation on the page. My guess is an error from an open tag is causing the problem.

http://validator.w3.org/
The page validates. Still no spoiler. The non showing spoiler is the last post on the first page.

http://www.leefish.nl/mybb/thread-3347.html

I am checking for uptodate versions of all plugins. I have a LOT - mostly things like MYBB publisher, XThreads (and Xthreads plugins), MyNetwork, Spamalyser.

I have added no plugins after I upgraded, and this has ONLY started happening post upgrade. I went from 1.6.3 to 1.6.7 in one go. I replaced ALL files, ran the upgrade, indicated 1.6.3 as my current version.
Is the spoiler issue only when a spoiler subject is used?
It is happening on ALL types of spoiler I have tried.

Here is my plugin list (it's at times like these when you need a spoiler tag Wink ):

Auto Unapprove Reported Posts (1.1)
Latest Downloads Stats on UserCP (1.1)
Cool Codes (1.24)
BBCode in Custom Profile Fields (1.0)
Creatorlink (1.1)
Custom Status (1.7)
Default Profile (2.1.0)
Latest Uploads Stats on UserCP (1.2)
Fresh Fish Attachments Gallery (1.1)
Game Section (1.2)
Gravatar (0.1)
Hide Sigs and Website of New Users (1.1)
Leesester's Graphs (1.0)
A plugin to display download information for Leefish
Forum Promotions (1.0)
Forum Name In Portal Announcement (1.0)
Format Name And Avatar In Thread List - XThreads Plugin (1.1)
Latest Or Random Images In Profile (1.0)
Display latest or random images in profile
Moderator notifications (1.5)
MyBBpublisher (1.7)
MyCodes Pack (1.0)
MyNetwork (1.1.2)
MyTracker (1.02)
Page Manager (1.5.2)
PHP and Template Conditionals (1.9)
Portal Pagination (1.0)
Portal Announcement Cut Off. (1.0)
Profile Comments (0.6.0)
Quick Theme! (1.1.2)
Registration Security Question (1.1)
RSS To Post (1.2.2)
SEO Titles (1.5)
Shadowbox.js (1.5)
Referral in Profile (1.1)
Spamalyser (0.92)
Thread Tooltip Preview (1.32)
Unapproved Threads (1.1)
View Unread Posts (2.6)
vB Style Quotes (1.13)
WhoIsInAjaxChat (0.4)
Wiki (Beta 3)
XThreads v1.47
XThreads Link Directory (1.0) 

The only ones that are out of date are Profile Comments and XThreads (it's a big change on this upgrade so I am preparing for that)

The plugins I first deactivated as potential issues were VBQuote, ThreadtoolTip and CoolCodes. That had no effect.

As I said earlier, there is a strange character appearing in the spoiler tag when you view source:

http://community.mybb.com/attachment.php?aid=26064

Some looking about on the web shows up that this is a Unicode Character 'ZERO WIDTH SPACE' (U+200B) . I have no idea why it should suddenly stop working though.
Then that is what is causing the problem. Im not getting that in my source code:

<a href="javascript:void(0);" onclick="javascript:if(parentNode.parentNode.getElementsByTagName('div')[1].style.display=='block'){parentNode.parentNode.getElementsByTagName('div')[1].style.display='none';this.innerHTML='(Click to View)';}else {parentNode.parentNode.getElementsByTagName('div')[1].style.display='block';this.innerHTML='(Click to Hide)';}">(Click to View)</a></div><div class="spoiler_body" style="display: none;">

Its not that bad it would happen in the
(Click to Hide)

Stuff, but it also happens in the code:
parentNode.parentNode.getElementsByTagName('div')

Which breaks the code.

Do you use any sort of (UTF-8 to Unicode/UTF-8 to Latin1) character conversion on your site? Another good suggestion would be to check your plugin.php file. And see if you have a space on those places to or something. (looked at your post with your plugin code, its not a problem with the plugin as far as i can see. Something else on your site is causing this)
It has to be something many users have in common - there are a heck of a lot of mybb users seeing this problem with spoilers.

As far as I am aware I have no such converter. Like I said - it was FINE until I upgraded from 1.6.3 to 1.6.7 - and then POW, no spoilers.

* Leefish is being driven slowly insane by this Big Grin
Pages: 1 2 3 4