I use Dragonfly CMS (version 9.1.2.1) for the gamer site I run. One feature it lacks is the BBCode strikethrough tag, which is normally [s] , and I wanted this to cross off items in a list that were no longer an option for an upcoming LAN party, so decided to add the functionality, it was very very simple and maybe there are already posts out there on how to do it, but if not here goes. Now, I didn't go as far as updting the editor GUI since those change based on the theme selected, but I did give the ability for my users to type in the raw tag and have it work great.
Steps to add [s] ... [/s] to Dragonfly's version of BBCode:
1. Open up nbbcode.php in the includes directory.
2. Search for "function decode". About 25 below that, you'll see where the [b], [u], and [i] tags are handled - they are commented. Each section is 3 lines with the comment.
3. Copy and paste the 3 lines. Change to look like the following:
# [s] and [/s] for striking out text
$patterns[] = '#\[s\](.*?)[/s\]#si';
$replacements[] = '< style="text-decoration:line-through"> \\1 < /span > ';
** Note ** The $replacements[] line may have wrapped to a new line and shouldn't. Also, I had to add spaces to the span tag for it to get approved to publish.
As far as what this does... The $patterns[]... line simply adds a search pattern that looks for any characters between [s] and [/s] - case insensitive. The $replacements[] line adds the complimenting replacement string to surround the text that was between [s] and [/s] with a tag (the "(.*?)" from the patterns line = "\\1" in the replacements line). Later in the same function, preg_replace is called to actually make the find/replace happen.
Friday, August 14, 2009
Subscribe to:
Comments (Atom)