I wanted a dropdown menu for spoilers, so I changed the spoiler.module on my local server:

function _spoiler_filter_process($text) {
  return preg_replace('#\[spoiler=?(.*?)\](.*?)\[/spoiler\]#s', t('<fieldset class="collapsible collapsed"><legend>Spoiler: $1</legend><div>$2</div></fieldset>'), $text);
}

With this, it kinda resembles BBCode that uses [spoiler][/spoiler] tags, as well as the optional title with [spoiler=Title][/spoiler].

It also renders nicely on handheld devices as expanded text, whereas I was having viewing issues with the old CSS method. On my system, I also changed the _filter_tips function and _filter description to reflect the new behavior.

If others think this is useful, would it be possible to add this as an option?

Comments

Zen’s picture

Version: 6.x-1.1-beta » 6.x-1.1-beta2
Status: Active » Closed (won't fix)

There's a new beta out with JS support and a theme function that you can use if necessary.

-K

Unity’s picture

Thanks for this great hack. IMO this version is much better than the original. I used it in my Drupal 5 version of Spoiler, and it works great!