1.下載解壓后codeblock復制到帝國cms后臺:/e/admin/ecmseditor/infoeditor/plugins下(注:admin 為系統(tǒng)默認地址,如果有自定義需要改為自定義文件名)
2.修改帝國cms編輯器配置文件,路徑:/e/admin/ecmseditor/infoeditor/config.js(大概在95行與110行后添加 , 'CodeBlock')
PS:一定要注意大小寫,否則會出現(xiàn)編輯器不顯示或顯示但沒有codeblock模塊的情況,完了刷新緩存,你就可以看到編輯器多了一個圖標。
3.修改后的源碼
- ?
- function EcmsEditorDoCKhtml(htmlstr){
- if(htmlstr.indexOf('"')!=-1)
- {
- return '';
- }
- if(htmlstr.indexOf("'")!=-1)
- {
- return '';
- }
- if(htmlstr.indexOf("/")!=-1)
- {
- return '';
- }
- if(htmlstr.indexOf("\\")!=-1)
- {
- return '';
- }
- if(htmlstr.indexOf("[")!=-1)
- {
- return '';
- }
- if(htmlstr.indexOf("]")!=-1)
- {
- return '';
- }
- if(htmlstr.indexOf(":")!=-1)
- {
- return '';
- }
- if(htmlstr.indexOf("%")!=-1)
- {
- return '';
- }
- if(htmlstr.indexOf("<")!=-1)
- {
- return '';
- }
- if(htmlstr.indexOf(">")!=-1)
- {
- return '';
- }
- return htmlstr;
- }
- function EcmsEditorGetCs(){
- var js=document.getElementsByTagName("script");
- for(var i=0;i<js.length;i++)
- {
- if(js[i].src.indexOf("ckeditor.js")>=0)
- {
- var arraytemp=new Array();
- arraytemp=js[i].src.split('?');
- return arraytemp;
- }
- }
- }
- var arraycs=new Array();
- arraycs=EcmsEditorGetCs();
- arraycs[0]=arraycs[0].replace('infoeditor/ckeditor.js','');
- arraycs[1]=document.getElementById('doecmseditor_eaddcs').value;
- arraycs[1]=EcmsEditorDoCKhtml(arraycs[1]);
- CKEDITOR.editorConfig = function( config ) {
- // Define changes to default configuration here. For example:
- // config.language = 'fr';
- // config.uiColor = '#AADC6E';
- config.filebrowserImageUploadUrl = '';
- config.filebrowserFlashUploadUrl = arraycs[0];
- config.filebrowserImageBrowseUrl = arraycs[1];
- config.filebrowserFlashBrowseUrl = arraycs[1];
- config.enterMode = CKEDITOR.ENTER_BR;
- config.shiftEnterMode = CKEDITOR.ENTER_P;
- config.allowedContent= true;
- config.font_names='宋體/宋體;黑體/黑體;仿宋/仿宋_GB2312;楷體/楷體_GB2312;隸書/隸書;幼圓/幼圓;微軟雅黑/微軟雅黑;'+ config.font_names;
- // Toolbar
- config.toolbar_full = [
- { name: 'document', groups: [ 'mode', 'document', 'doctools' ], items: [ 'Source', '-', 'Preview', 'Print' ] },
- { name: 'clipboard', groups: [ 'clipboard', 'undo' ], items: [ 'Cut', 'Copy', 'Paste', 'PasteText', 'PasteFromWord', '-', 'Undo', 'Redo' ] },
- { name: 'paragraph', groups: [ 'list', 'indent', 'blocks', 'align', 'bidi' ], items: [ 'NumberedList', 'BulletedList', '-', 'Outdent', 'Indent', '-', 'Blockquote', 'CreateDiv', '-', 'JustifyLeft', 'JustifyCenter', 'JustifyRight', 'JustifyBlock', '-', 'BidiLtr', 'BidiRtl' ] },
- '/',
- { name: 'basicstyles', groups: [ 'basicstyles', 'cleanup' ], items: [ 'Bold', 'Italic', 'Underline', 'Strike', 'Subscript', 'Superscript', '-', 'RemoveFormat', 'ecleanalltext', 'autoformat' ] },
- { name: 'links', items: [ 'Link', 'Unlink', 'Anchor' ] },
- { name: 'insert', items: [ 'Image', 'etranmore', 'Flash', 'etranmedia', 'etranfile', '-', 'Table', 'HorizontalRule', 'SpecialChar', 'equotetext', 'einserttime', 'einsertpage', 'einsertbr', 'CodeBlock' ] },
- '/',
- { name: 'styles', items: [ 'Styles', 'Format', 'Font', 'FontSize' ] },
- { name: 'colors', items: [ 'TextColor', 'BGColor' ] },
- { name: 'tools', items: [ 'ShowBlocks', 'NewPage', 'Templates' ] },
- { name: 'others', items: [ '-' ] },
- { name: 'editing', groups: [ 'find', 'selection', 'spellchecker' ], items: [ 'Find', 'Replace', '-', 'SelectAll', 'Maximize' ] }
- ];
- // Toolbar
- config.toolbar_basic = [
- { name: 'document', groups: [ 'mode', 'document', 'doctools' ], items: [ 'Source' ] },
- { name: 'clipboard', groups: [ 'clipboard', 'undo' ], items: [ 'Cut', 'Copy', 'Paste', 'PasteText', 'PasteFromWord', '-', 'Undo', 'Redo' ] },
- { name: 'links', items: [ 'Link', 'Unlink', 'Anchor' ] },
- { name: 'insert', items: [ 'Image', 'Table', 'HorizontalRule', 'SpecialChar', 'CodeBlock' ] },
- { name: 'tools', items: [ 'Maximize' ] },
- { name: 'others', items: [ '-' ] },
- '/',
- { name: 'basicstyles', groups: [ 'basicstyles', 'cleanup' ], items: [ 'Bold', 'Italic', 'Strike', '-', 'RemoveFormat' ] },
- { name: 'paragraph', groups: [ 'list', 'indent', 'blocks', 'align', 'bidi' ], items: [ 'NumberedList', 'BulletedList', '-', 'Outdent', 'Indent', '-', 'Blockquote' ] },
- { name: 'styles', items: [ 'Styles', 'Format' ] }
- ];
- config.extraPlugins = 'etranfile,etranmedia,etranmore,autoformat,ecleanalltext,einsertbr,einsertpage,einserttime,equotetext,codeblock';
- config.toolbar = 'full';
- };
4.模板調用:
壓縮包里contents.css 文件復制到/skin下你站點的css文件夾里,在內容頁引入CSS文件即可(skin為系統(tǒng)默認地址,如果有自定義需要改為自定義文件名)。
- <link href="[!--news.url--]skin/css/contents.css" rel="stylesheet">