Help - Search - Members - Calendar
Full Version: How to disable HTML code escaping in 'edit_entry.t
Movable Type Community Forum > Additional Resources > Tips and Tricks
agiel
Hi

I am trying to replace the default entry editor by an HTML editor such as this one (http://www.fredck.com/FCKeditor/ ).

I got the editor to work just fine except for one thing :

When I edit an entry, all HTML codes are replaced by their escaped equivalent.

For example : becomes </A>

This makes WYSIWYG editing completely useless smile.gif

Can anybody point me to the right direction to disable this text filter before displaying the editable text ?
kadyellebee
I would suggest asking that question to the FCKeditor people. This may be considered a *feature* of their editor, but maybe there's a way to turn that off...

Kristine
agiel
I doubt it is a feature of that editor. I get the same behaviour from the default editor from MT.

When you edit an entry with links, URLs appear as HTML code in the text area. When you look at the source of the page, the HTML code is displayed with > symbols instead. This means MT is filtering HTML code before editing an article and then filtering these codes back to HTML after editing is done.

This is the filtering I want to disable.
girlie
I'm completely confused by what you're saying. When I enter a URL into an entry using HTML, it becomes a link on the page. And HTML is supposed to be surrounded with < and >.

So what is it you're saying that I'm not understanding?
agiel
Ok... I guess I was too focused on my particular problem to explain the issue properly, so lets backtrack a little bit.

Here is what MT editor is doing : when you add a new link, it automatically creates the HTML code for that link. So what you see on your form is (for example).

<a href="http://www.renderosity.com/homepage.ez?Who=agiel">Personal gallery</a>

But if you look at the source of your page, what is actually in the page is :

< textarea class="width500" name="text" rows="20" wrap="virtual" >

& lt ; a href="http://www.renderosity.com/homepage.ez?Who=agiel" & gt ;Personal gallery& glt ;/a & gt ;

< /textarea >

So, MT has to convert '<' '>' symbols to '& lt ;' and '& gt ;' in order to display them correctly in the editor and convert them back to their original value to be displayed correctly in the final HTML page.

Now, when you use a WYSIWYG editor, the editor is doing that conversion for you byt displaying URLs as clickable links directly in the editor, and not just as HTML code.

So what I want to see in the source of the page is :


< open HTML editor >

<a href="http://www.renderosity.com/homepage.ez?Who=agiel">Personal gallery</a>

< closeHTML editor >


This is why I am looking into turning off that 'filter' that MT seems to apply to entries in edit mode.

I hope this is a little more clear
agiel
Actually, I found two procedures 'html_encode' and 'html_decode' in the 'Util.pm' module.

I guess these are what I was looking for.... now I just have to understand how to prevent them to be called for the entry body only.
agiel
Got it !

It took some time to figure it out, but the solution is relatively simple.

Just add :

if ($type eq 'entry') { $param{'text'} = decode_html($param{'text'})};

before line 847 in the module CMS.pm

line 847: return $app->build_page("edit_${type}.tmpl", \%param);

and add 'decode_html' to the list of procedures loaded by the same module:

line 11: use MT::Util qw( encode_html decode_html format_ts offset_time_list remove_html get_entry );

This will effectively disable the automatic HTML encoding for the 'entry body' field and make it possible to replace the main textarea by an HTML editor.

I know it is not ideal to edit one of the core modules, so if someone has another suggestion, I am open to apply it smile.gif
agiel
I summarized the solution on my site under :

How to replace the default entry textarea by an HTML editor

Here is a picture of the resulting modification :

Screenshot
efurban
Thanks for the great information about how to make fckeditor work for movable. I got everything working fine now with the fckeditor except the new entry created by adding a file.

It seems that the FCKeditor is not created when you add a new entry. sad.gif anybody hit this before ?

Thanks.
Raffaele
This editor is very good. I use MovableType version 2.65

I have put this code into the ’edit_entry.tmpl’ template (MT/tmpl/cms folder).


CODE
<head>
<script language="javascript" src="/FCKeditor/fckeditor.js"></SCRIPT>
</head>


and then I have put this code

CODE
<tr>
 <td width="402"><font class="pagetitle"><MT_TRANS phrase="Entry Body"></font></td>
 </tr>

<tr>
    <td width="100%" valign="top">
       <script language="javascript">
<!--
var oFCKeditor;
oFCKeditor = new FCKeditor('EditorDefault');
<!--oFCKeditor.Value = 'Exemple'; -->
oFCKeditor.Config['StyleNames'] = ';Style 1;Style 2; Style 3';
oFCKeditor.Config['ToolbarFontNames'] = ';Arial;Courier New;Times New Roman;Verdana';
oFCKeditor.Create();
//-->
     </SCRIPT>

</td>    
</tr>


Everything goes well. I write into the Entry Body, then I "save" the post, but once I did this operation what I wrote into the Entry Body isn't shown.
why? Can you help me?

Thank you for your helping.
Raffaele
Italy
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Invision Power Board © 2001-2009 Invision Power Services, Inc.