You are here:Home»KB»Web Design»CMS»Joomla»Extensions»Prevent Code stripping in FCKeditor
Friday, 12 June 2009 12:29

Prevent Code stripping in FCKeditor

Written by

This prevents code stripping or manipulation of code between the geshibot tags (using curly braces) in FCKeditor WYSIWYG. (or anyother specified tag)

Firstly make sure you have set Joomla's whitelist/blacklist thing properly as descibed in this article.

http://docs.joomla.org/Why_does_some_HTML_get_removed_from_articles_in_version_1.5.8%3F

The easiest way of checking this is to turn off your editor, paste some code in, save the article and see if joomla has stripped the code out.

Next choose FCKeditor as your WYSIWYG, install if needed.

To prevent any code in between the geshibot tags being stripped out we need to add a line of code to

/plugins/editors/fckeditor/fckconfig.js

search for (about line 66):

{code class="brush: text"}// FCKConfig.ProtectedSource.Add( /(]+>[\s|\S]*?<\/asp:[^\>]+>)|(]+\/>)/gi ) ; // ASP.Net style tags {/code}

right below it add:

{code class="brush: text"}FCKConfig.ProtectedSource.Add( /{geshibot[\s\S]*?}[\s\S]*?{\/geshibot}/g ) ; // Protects all code between GESHI tags{/code}

or another example using code and curly braces

{code class="brush: text"}FCKConfig.ProtectedSource.Add( /{code[\s\S]*?}[\s\S]*?{\/code}/g ) ; // Protects all code between code tags{/code}

Save file, empty you browser cache to make sure nothing is left. FCKeditor will now leave all code between the geshibot tags alone.

This code will allow you to specify the parameters of Geshibot in the first bracket aswell.

Please note, when you uninstall or upgrade this change will dissapear and will have to mod the file again. Also, the geshibot tags and the code between it will only be visible on the source page.

This technique can be used to protect other needed tags for FCKeditor

The following instructs FCKeditor to accept the tags <MYTAG> and <CUSTOM> . The following protects tags that are in the normal html entity style with the greater and lesser than signs

{code class="brush: text"}FCKConfig.ProtectedTags = 'MYTAG|CUSTOM' ;{/code}

Read 1198 times Last modified on Saturday, 05 May 2012 20:10