Spoiler tag with spoiler title issue

Discussion forum for MOD Writers regarding MOD Development.
User avatar
Registered User
Posts: 34
Joined: Fri Nov 23, 2007 12:25 am

Spoiler tag with spoiler title issue

Post by shadow07 » Mon Jan 07, 2008 8:51 am

ok I found this spoiler code in which the tags are like this [Spoiler=title]text[/Spoiler]

How would I get this lowe=r thing toi work, also I read that the person who made this had the folowing problem..
.i made the [spoiler=] tag based on the info on the [spoiler] tag . the [spoiler]text[/spoiler] and the [spoiler=title]text[/spoiler] tags both work but .. the [spoiler=title] tag can only be used once in a post. since the ids for the [spoiler=] are the same (cause of the time). but the [spoiler] has different ids cause it does each tag one at a time. im not really a php programmer and have a question

Code: Select all

        //spoiler hackkkk
        $patterns[] = "/\[spoiler=(.*)\]/sU";       
            $sph =  "<!--SPOILER BEGIN--><div class=\"spoilertop\" onClick=\"openClose('".$obj=md5(microtime());
            $sph .= "')\" style=\"font-weight: bold\" /><u>&raquo; Spoiler: \\1  &laquo;</u /></div />";
            $sph .= "<div class=\"spoilermain\" id=\"".$obj."\" style=\"display:none\" /><!--SPOILER END-->";
            $replacements[] = $sph; 
        $patterns[] = "/\[\/spoiler]/sU";
        $replacements[] = '<!--SPOILER DIV--></div /><!--SPOILER DIV-->';   
        $text = $this->spoilerConv($text); 
        //end spoiler hackkk
        $patterns[] = "/\[quote]/sU";
        $replacements[] = _QUOTEC.'<div class="xoopsQuote"><blockquote>';
        //$replacements[] = 'Quote: <div class="xoopsQuote"><blockquote>';
        $patterns[] = "/\[\/quote]/sU";
        $replacements[] = '</blockquote></div>';
        $patterns[] = "/java script:/si";
        $replacements[] = "java script:";
        $patterns[] = "/about:/si";
        $replacements[] = "about :";
        return preg_replace($patterns, $replacements, $text);
//begin spoiler hack function

    function spoilerConv($inbx)
        preg_match_all("#\[spoiler\]#is"   , $inbx, $numbx);
        $ibx = count($numbx[0]);
        $abx = 0;
        $vbx = 0;
        while($abx < $ibx)
      $outbx =  "<!--SPOILER BEGIN--><div class=\"spoilertop\" onClick=\"openClose('".$obj=md5(microtime());
            $outbx .= "')\" style=\"font-weight: bold\"><u>&raquo; "._SPOILERSHOW." - "._SPOILERHIDE." : &laquo;</u></div>";
            $outbx .= "<div class=\"spoilermain\" id=\"".$obj."\" style=\"display:none\"><!--SPOILER END-->";
            $inbx = preg_replace("#\[spoiler\]#is", $outbx, $inbx, 1);
        while($vbx < $ibx)
            $inbx = preg_replace("#\[\/spoiler\]#is", "<!--SPOILER DIV--></div><!--SPOILER DIV-->", $inbx, 1);

        return $inbx;


User avatar
Former Team Member
Posts: 34457
Joined: Sat Jan 18, 2003 1:26 am
Location: Where the Rivers Run

Re: Spoiler tag with spoiler title issue

Post by A_Jelly_Doughnut » Mon Jan 07, 2008 2:39 pm

To me, this looks like a phpBB2 MOD. If you're trying to port it to phpBB3, you can save a lot of time by using the custom BBCodes feature ... there is a sticky topic in the phpBB3 support fourm that can help with this.
A Donut's Blog
"Bach's Prelude (Cello Suite No. 1) is driving Indiana country roads in Autumn" - Ann Kish


Return to “[3.0.x] MOD Writers Discussion”