Page 1 of 1

PHP spoiler tags pattern and replacement problem.

Posted: Sat Aug 13, 2005 12:30 pm
by Pint
I'm trying to modify my xmb forum to use spoiler tags,
The part i'm having trouble with is getting the right replacement for the tags

Code: Select all

$patterns[] = "#\[spoiler\]([:a-z\\./_\-0-9%~]+){1}(\?[a-z=_\-0-9&;~]*)?\[/spoiler\]#mi";
        $replacements[] = '<div class="spoiler" style="padding: 3px;" align="center" width="100%"><a href="javascript://" OnClick="javascript: layerVis(\''.$rnd.'\', 1);">Reveal Spoiler</a><div align="left" id="'.$rnd.'" style="visibility: hidden;">\1</div></div>';
This replaces the spoiler tags with a reveal box or at least it's supposed to anyway.
The reveal spoiler part comes up but nothing else.

Here's the source code of that part in the page produced

Code: Select all

<div class="spoiler" style="padding: 3px;" align="center" width="100%"><a href="javascript://" OnClick="javascript: layerVis('',
1);">Reveal Spoiler</a><div align="left" id="" style="visibility: hidden;">Text</div></div>
Any ideas?
I should probably add that i know next to nothing about PHP and that i'm only starting to learn by adding hacks and modifications to my forum.

JCART | Please use

Code: Select all

tags when posting php code. Review [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url][/color]

Posted: Sat Aug 13, 2005 1:20 pm
by John Cartwright
Moved to Regex.

Posted: Sat Aug 13, 2005 2:24 pm
by Pint
I did originally use php but it changed the

Code: Select all

javascript://
into

Code: Select all

javascript://
so i thought better of it.

Posted: Sat Aug 13, 2005 2:50 pm
by feyd
$rnd isn't set when the string is created.

Posted: Sat Aug 13, 2005 3:00 pm
by Pint
Thank you so much. It's working perfectly now i think.
Feel a little :oops: though....

Thanks :D

Posted: Sat Aug 13, 2005 4:35 pm
by Chris Corbyn
Pint wrote:Feel a little :oops: though....
Don't. Everyone does stuff like that even when you've been doing it for years ;)

Welcome to the forums :D