官方提供的集成fckeditor到mt中的方法

在fckeditor的网站上发现的,链接点这里
 
这一个的集成方法比较好,可以让日记主要内容、更多日记内容、日记关键字,都集成fckeditor。
 
其实对比以前的方法,在edit_entry.tmpl文件的<head>与</head>中间,加入
<script type="text/javascript" src="你的fckeditor的js地址"></script>
<script type="text/javascript">
window.onload = function()
 {
 var oFCKeditor = new FCKeditor( ‘text’ ) ;
  oFCKeditor.Height = "400" ;
  oFCKeditor.Width = "580" ;
  oFCKeditor.CheckBrowser = true ;
  oFCKeditor.ReplaceTextarea() ;
 
  pFCKeditor = new FCKeditor( ‘text_more’ ) ;
  pFCKeditor.Height = "400" ;
  pFCKeditor.Width = "580" ;
  pFCKeditor.CheckBrowser = true ;
  pFCKeditor.ReplaceTextarea() ;
}
    </script>
 
就可以实现了如果需要让关键字也增加格式

下面这些,是原文,这个更加完善一点
 
1、Download FCKeditor (the version I used is 2.0 FC) and unzip the downloaded file in your MT static directory. This will result in a directory named FCKeditor.
 
2、Open the file [MT installation dir]/tmpl/cms/header.tmpl  and save it as: header_edit_entry.tmpl
 
3、Add the following code to header_edit_entry.tmpl between the tags <head> … </head>:
 
   <script type="text/javascript"
      src="<TMPL_VAR NAME=STATIC_URI>FCKeditor/fckeditor.js"></script>
 
   <script type="text/javascript">
      window.onload = function()
      {
        var oFCKeditor = new FCKeditor( ‘text’ ) ;
        oFCKeditor.BasePath = ‘<TMPL_VAR NAME=STATIC_URI>FCKeditor/’ ;
        oFCKeditor.Width = 580 ;
        oFCKeditor.Height = 400 ;
        oFCKeditor.CheckBrowser = true ;
        oFCKeditor.ReplaceTextarea() ;
 
        pFCKeditor = new FCKeditor( ‘text_more’ ) ;
        pFCKeditor.BasePath = ‘<TMPL_VAR NAME=STATIC_URI>FCKeditor/’ ;
        pFCKeditor.Width = 580 ;
        pFCKeditor.Height = 400 ;
        pFCKeditor.CheckBrowser = true ;
        pFCKeditor.ReplaceTextarea() ;
           
        qFCKeditor = new FCKeditor( ‘excerpt’ ) ;
        qFCKeditor.BasePath = ‘<TMPL_VAR NAME=STATIC_URI>FCKeditor/’ ;
        qFCKeditor.ToolbarSet = "MTExcerpt" ;
        qFCKeditor.Width = 580 ;
        qFCKeditor.Height = 200 ;
        qFCKeditor.CheckBrowser = true ;
        qFCKeditor.ReplaceTextarea() ;
      }
    </script>
 
4、Open the file [MT installation dir]/tmpl/cms/edit_entry.tmpl and replace <TMPL_INCLUDE NAME="header.tmpl"> with <TMPL_INCLUDE NAME="header_edit_entry.tmpl">
 
5、Delete in the same file (edit_entry.tmpl) the quicklinks. These are the B, I, U etc. buttons that appear above the Entry Body and Extended Entry textareas. Delte the following code twice:
<script type="text/javascript">
<!–
if (canFormat) {
    with (document) {
        write(‘<a title="<MT_TRANS phrase="Bold" escape="singlequotes">
[…]
    }
}
// –>
</script>
 
Notice: You will have to delete this code once for the Entry Body and once for the Extended Entry.
 
6、Now it is time to edit the FCKeditor configuration file (fckconfig.js). You will have to remove the editor functions you don’t use and that might be confusing to your users  (for instance the New File button and the Save button). I edited the Default Toolbarset, but you can also create a new Toolbarset. If you do so you will also have to edit the code under step 3.  I use the Default Toolbarset for the Entry Body and the Extended Entry.
 
Replace the existing Default ToolbarSet code with:
 
FCKConfig.ToolbarSets["Default"] = [
[‘Source’],
[‘Cut’,’Copy’,’Paste’,’PasteText’,’PasteWord’,’-‘],
[‘Undo’,’Redo’,’-‘,’Find’,’Replace’,’-‘,’SelectAll’,’RemoveFormat’],
[‘Bold’,’Italic’,’Underline’,’StrikeThrough’,’-‘,’Subscript’,’Superscript’],
[‘OrderedList’,’UnorderedList’,’-‘,’Outdent’,’Indent’],
[‘JustifyLeft’,’JustifyCenter’,’JustifyRight’,’JustifyFull’],
[‘Link’,’Unlink’,’Anchor’],
[‘Image’,’Table’,’Rule’,’Smiley’,’SpecialChar’,’UniversalKey’]  , 
[‘Form’,’Checkbox’,’Radio’,’TextField’,’Textarea’,’Select’,’Button’,’ImageButton’,’HiddenField’],
‘ /’,
[‘Style’,’FontFormat’,’FontName’,’FontSize’],
[‘TextColor’,’BGColor’],
[‘About’]
] ;
 
7、Next I have created a more restricted Toolbarset for the Excerpt. Add the folowing code:
 
FCKConfig.ToolbarSets["MTExcerpt"] = [
 [‘Source’],
 [‘Bold’,’Italic’,’Underline’,’-‘,’OrderedList’,’UnorderedList’,’-‘,’Link’,’Unlink’,’-‘,’About’]
] ;
 
8、Finally deactivate the built-in image and linkbrowser:
 
FCKConfig.LinkBrowser = false ;
FCKConfig.ImageBrowser = false ;
 
9、That’s all! Good luck! 

Leave a Reply

Your email address will not be published. Required fields are marked *