2010-08-30 73 views
2

我正在使用CKEditor和PHP。CKEditor PHP集成

使用PHP代码变量得到回显的示例PHP打印触发CKEditor显示的代码。我只在一个真实的布局中做同样的事情,编辑器会将其中的侵蚀HTML吞没,就好像它是它的initialValue一样。

任何想法,为什么我得到这个,请?

下面是代码:

// Include CKEditor class. 
@require_once("ckeditor/ckeditor.php"); 

// Create class instance. 
$CKEditor = new CKEditor(); 

// Do not print the code directly to the browser, return it instead 
$CKEditor->returnOutput = true; 

// Path to CKEditor directory, ideally instead of relative dir, use an absolute path: 
// $CKEditor->basePath = '/ckeditor/' 
// If not set, CKEditor will try to detect the correct path. 
$CKEditor->basePath = 'ckeditor/'; 

// Set global configuration (will be used by all instances of CKEditor). 
$CKEditor->config['width'] = 600; 

// Change default textarea attributes 
//$CKEditor->textareaAttributes = array("cols" => 80, "rows" => 10); 

//Set formatting options 
$config['toolbar'] = array(
    array('Source','-', 
      'NewPage','Preview','Templates','-', 
      'Cut','Copy','Paste','PasteText','PasteFromWord','-', 
      'Undo','Redo','-', 
      'Find','Replace','-', 
      'SelectAll','RemoveFormat','-', 
      'Maximize', 'ShowBlocks'), 
    '/', 
    array('Bold','Italic','Underline','Strike','-', 
      'Subscript','Superscript','-', 
      'NumberedList','BulletedList','-', 
      'Outdent','Indent','Blockquote','-', 
      'JustifyLeft','JustifyCenter','JustifyRight','JustifyBlock','-', 
      'Link','Unlink','Anchor','-', 
      'Image','Flash','Table','HorizontalRule','SpecialChar' 
     ), 
    '/', 
    array('Format','Font','FontSize','-', 
      'TextColor','BGColor') 
); 

//Set skin 
//$config['skin'] = 'kama';//kama si defailt skin for 3.4 

//Set language and UI Color 
$config['language']='ro'; 
//$config['uiColor']='#AADC6E'; 


//Remove the html tags in the status bar (e.g. body p strong for when cursor is in a strong tag within a p tag within the body) 
$config['removePlugins']='elementspath'; 

//Allow/deny resizing of editor from dragging the bottom-right corner. Maximize will still work. 
$config['removePlugins']='resize';//Remove resize image 
$config['resize_enabled ']=false;//Disallow resizing 

//Remove the collapse formatting area button (arrow on the middle-right part of the editor 
//$config['toolbarCanCollapse']=false; 

// The initial value to be displayed in the editor. 
$initialValue = ''; 

//Add the CKFinder for upload of files directly from the `Add Image`/`Add Flash` buttons. 
include_once($CKEditor->basePath.'ckfinder/ckfinder.php'); 
// You can use the "CKFinder" class to render CKFinder in a page: 
$finder = new CKFinder(); 
$finder->BasePath = 'ckeditor/ckfinder/'; // The path for the installation of CKFinder (default = "/ckfinder/"). 
//$finder->SetupCKEditor($CKEditor,$CKEditor->basePath.'/ckfinder/'); 

// Create first instance. 
$CKEditorOutput = $CKEditor->editor("continut",$initialValue,$config); 

后来,我只是做:$output.='<div>'.$CKEditorOutput.'</div>; 当然,围绕其中的CKEditor所在的DIV布局大。

谢谢!

+3

请问我们可以有一些代码! – 2010-08-30 17:43:42

+0

是的,我们真的需要看到你的描述超模糊。 – Iznogood 2010-08-30 17:46:40

+0

添加了代码,谢谢。 – Francisc 2010-08-31 10:05:18

回答

2

啊,我明白了...

这条线:$CKEditorOutput = $CKEditor->editor("continut",$initialValue,$config);

布局包含的“continut”的ID选择一个div,所以<div id="continut">.因此搞乱了一切,并开启该分区和所有内部HTML进入RTE Textarea。

对不起,谢谢大家!

+1

如果问题得到解决,请不要忘记将自己的答案标记为已接受。 – Sk8erPeter 2011-12-01 19:13:36

+0

谢谢。忘记了,直到两天过去了。伟大的规则可能会增加... – Francisc 2011-12-02 20:53:58

+0

好吧,没问题:)) – Sk8erPeter 2011-12-02 22:25:53