Spoiler Tag

From PunBB Resource Wiki

Jump to: navigation, search

Well, It's a spoiler tag mod.

Contents

How to install?

PHP

Open includes/parser.php, and search for

$replace = array('<strong>$1</strong>',
	 '<em>$1</em>',
	 '<span class="bbu">$1</span>',
	 'handle_url_tag(\'$1\')',
	 'handle_url_tag(\'$1\', \'$2\')',
	 '<a href="mailto:$1">$1</a>',
	'<a href="mailto:$1">$2</a>',
	 '<span style="color: $1">$2</span>');

Right after it, add this:

// (MOD: Spoiler tag)
$pattern[] = "/\[spoiler\]([\s\S]*)\[\/spoiler\]/i";
$replace[] = '<span class="spoiler"><a href="javascript:void(0);">'.$lang_common['BBCode Spoiler'].'</a><span>: $1 <strong>'.$lang_common['BBCode Spoiler end'].'</strong></span></span>';
$pattern[] = "/\[spoiler=\"?(.*?)\"?\]([\s\S]*)\[\/spoiler\]/i";
$replace[] = '<span class="spoiler"><a href="javascript:void(0);">'.$lang_common['BBCode Spoiler for'].'$1</a><span>: $2 <strong>'.$lang_common['BBCode Spoiler end'].'</strong></span></span>';

Save and close parser.php. Open lang/English/common.php (or whatever language you are using), and search for

'BBCode error 4'	=> 'Missing one or more end tags for [quote].',
'BBCode error 5'	=> 'Missing one or more start tags for [/quote].',

Right after it, add this:

// (MOD: Spoiler tag)
'BBCode Spoiler'	=> 'SPOILER',
'BBCode Spoiler for'	=> 'SPOILER for ', // the spoiler subject will be appended to this string
'BBCode Spoiler end'	=> '(SPOILER ends)',

Save and close /lang/English/common.php.

CSS

Open style/imports/base.css Add in the end of the file (or anywhere else you want to)

/* (MOD: Spoiler tag) */
.spoiler span { display: none; }
.spoiler a { font-weight: bold; }

Save and close style/imports/base.css.

Javascript

Download jQuery , save it as jquery.js in a directory named "scripts" in the root directory. Create a file named scripts.js in the same directory, and put this inside it:

$(function() {
 
	// (MOD: Spoiler tag)
	$("span.spoiler a").toggle(function() {
		$(this).next().css("display","inline");
	},function() {
		$(this).next().css("display","none");
	});
 
});


Templates

(Updated by Runar, thanks to Smartys) Now open your main.tpl file and add this before <pun_head>:

<script type="text/javascript" src="scripts/jquery.js"></script>
<script type="text/javascript" src="scripts/scripts.js"></script>


--Poetic scarecrow 21:11, 15 January 2007 (GMT)

Personal tools
Namespaces
Variants
Actions
Navigation
Toolbox