Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

Forum Module /

Discuss the Forum Module.

Moderators: martimiz, Sean, biapar, Willr, Ingo, swaiba

Using the TinyMCE BBCode plugin?


Go to End
Reply


3 Posts   1695 Views

Avatar
DryerLintPurple

Community Member, 7 Posts

9 October 2013 at 6:00pm

TinyMCE has a BBCode plugin for forums available. Hell, it's already right there in the TinyMCE bundle that comes with SS framework. (\framework\thirdparty\tinymce\plugins\bbcode)

So, uh, why isn't it being used?

Granted, the plugin is based on punBB's dialect of BBCode, while IIRC SS uses whatever was on PEAR at the time (looked at any alternatives?). So some tweaking would probably be needed, but the plugin is little more than a set of regexps, so I doubt it would take too much.

So what would be involved in this? Obviously you'd need a custom HTMLEditorConfig, and the post form would have to be changed to HTMLEditorField. But the actual data fields in the Forum module wouldn't need to change since it's still unparsed BBCode being sent from the user, right?

Avatar
davepolyester

Community Member, 53 Posts

24 June 2014 at 5:02pm

Did you ever make any headway with this? I have a client crying out for some simple WYSIWYG formatting for Posts in the Forum module.

Avatar
davepolyester

Community Member, 53 Posts

12 June 2015 at 5:20pm

Edited: 15/06/2015 4:51pm

Hey, I just got this working!

After posting to this thread last year, I finally decided to give it a shot today, and it was dead easy!

Here's my process:
1. Copied the sample script from the BBCode example on the TinyMCE website and pasted at the top of the template files Forum_editpost.ss, Forum_reply.ss and Forum_starttopic.ss (or as an Include)
2. Updated the tiny_mce.js source location to framework/thirdparty/tinymce/tiny_mce.js
2. Changed the mode to "textareas" in the script.

And bingo - it works! Can happily format text, add links and images, etc with no probs.

Can someone much more clued-up than me please check this and let me know if there are any security issues or other problems with what I've done?

Edit:
Have hit a glitch with the validation when replying to a post. It seems the validation is being parsed before the TinyMCE editor renders the content into BBcode or some such thing, so it thinks the "Content" field is empty. My nasty solution is to remove the validation but it seems to allow all "Content" fields to be left empty, not just ones on reply. Approx line 822 of Forum.php:

$required = $addMode === true ? new RequiredFields("Title", "Content") : new RequiredFields(/*"Content"*/);// --- Second "Content" validation instance commented out to make compatible with TinyMCE plugin. ---

A better solution would be appreciated.
Edit:
I've made a few other tweaks to improve this implementation:
1. Removed the styleselect item from the theme_advanced_buttons1 line of the script as this functionality is only supported by the PunBB dialect.
2. Added the following text to Forum_BBCodeHint.ss: Note: Some BB Code tags are not available from the tool bar. To manually add other BB Code tags to your content, click the HMTL button in the toolbar first.