News:

SMF 2.1.4 has been released! Take it for a spin! Read more.

Main Menu

A Spoiler Tag Is Giving Me Errors

Started by Mr Blah Man, November 24, 2007, 06:10:50 AM

Previous topic - Next topic

Mr Blah Man

Okay.

I used THIS MOD and installed it manually (Using the Packages Installation Thing won't work for me).

I'm POSITIVE I did everything right.

But I get this:

Quote
Fatal error: Cannot redeclare get_spoiler() (previously declared in /home/ryanslai/public_html/ShadowLegion/Forums/Sources/Subs.php:919) in /home/ryanslai/public_html/ShadowLegion/Forums/Sources/Subs.php on line 919

If I remove it, I get no errors except when i post a thread with the spoiler tag.

This is what I added (From Line 918 -> 975 in Subs.php)

// Spoiler choosing function
function get_spoiler($content, $topic = '') {
global $txt, $settings, $context, $modSettings;

// Optional topic if given
if($topic != '')
$topic = ': '.$topic;

// Backup if theme does not have included
$settings['spoiler_tag'] = isset($settings['spoiler_tag']) ? $settings['spoiler_tag'] : 0;
if($settings['spoiler_tag'] == 0) {
$settings['spoiler_tag'] = isset($modSettings['defaultSpoilerStyle']) ? $modSettings['defaultSpoilerStyle'] : 1;
}
$txt['spoiler_tag_text'] = isset($txt['spoiler_tag_text']) ? $txt['spoiler_tag_text'] : 'Spoiler';
$txt['spoiler_tag_hover_info'] = isset($txt['spoiler_tag_hover_info']) ? $txt['spoiler_tag_hover_info'] : '(hover to show)';
$txt['spoiler_tag_click_info'] = isset($txt['spoiler_tag_click_info']) ? $txt['spoiler_tag_click_info'] : '(click to show/hide)';

// Nothing to see here, move along.
if(!allowedTo('spoiler_show'))
return '';

/*
3: button
2: link
1: hover (default default)
*/
$retval = '';
switch($settings['spoiler_tag']) {
case 3:
$retval = (
'<div class="spoiler"><div class="spoilerheader">'.
'<input type="button" class="spoilerbutton" value="'.$txt['spoiler_tag_text'].$topic.'" '.
'onClick="n = this.parentNode.parentNode.lastChild;if(n.style.display == \'none\') {n.style.display = \'block\';} else {n.style.display = \'none\';} return false;"/> '.
$txt['spoiler_tag_click_info'].'</div><div class="spoilerbody" style="display: none">'.
$content.'</div></div>'
);
break;
case 2:
$retval = (
'<div class="spoiler"><div class="spoilerheader">'.
'<a href="javascript:void(0)" '.
'onClick="n = this.parentNode.parentNode.lastChild; if(n.style.display == \'none\') { n.style.display = \'block\'; } else { n.style.display = \'none\'; } return false;">'.$txt['spoiler_tag_text'].$topic.'</a> '.
$txt['spoiler_tag_click_info'].'</div><div class="spoilerbody" style="display: none">'.
$content.'</div></div>'
);
break;
case 1:
default:
$retval = (
'<fieldset class="spoiler" '.
'onMouseOver="this.lastChild.style.display = \'block\';" onMouseOut="this.lastChild.style.display=\'none\'">'.
'<legend><b>'.$txt['spoiler_tag_text'].$topic.'</b> <small>'.$txt['spoiler_tag_hover_info'].'</small>'.
'</legend><div class="spoilerbody" style="display: none">'.
$content.'</div></fieldset>'
);
}
return $retval;
};


And I added that UNDER:

// The current time with offset.
function forum_time($use_user_offset = true, $timestamp = null)
{


If you need my FULL Subs.php or something else, let me know.

Thanks,
Mr Blah Man.

Kays

That error usually indicates that the function has been added twice.

QuoteAnd I added that UNDER:



// The current time with offset.
function forum_time($use_user_offset = true, $timestamp = null)
{

That should go before, not after. Are you using the mod parser to get the add postions? You might be doing it all backwards.

For boardmod you add the code "after" the search position. For XML the search position is "after" the code. It can be confusing.

If at first you don't succeed, use a bigger hammer. If that fails, read the manual.
My Mods

Mr Blah Man

#2
Oh okay.

I didn't add it twice, but i added it AFTER that bit of code.

I'll see if it works now.

You learn something new everyday.

EDIT: Yay! Thank you very much :)

Advertisement: