CKEditor PHP интеграция - PullRequest
       6

CKEditor PHP интеграция

2 голосов
/ 30 августа 2010

Я использую CKEditor с PHP.

Используя пример PHP, где переменная $ code отображается, печатая код, который вызывает показ CKEditor.Я делаю то же самое только в реальном макете, и в результате редактор поглощает внутри себя замещающий HTML, как если бы он был его начальным значением.

Любая идея, почему я получаю это, пожалуйста?

Вот код:

// 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>; Конечно, расположение вокруг div, в котором находится CKEditor, больше.

Спасибо!

1 Ответ

2 голосов
/ 31 августа 2010

Ах, понял ...

Эта строка: $CKEditorOutput = $CKEditor->editor("continut",$initialValue,$config);

Макет содержит div с селектором идентификатора «continut», так что <div id="continut">. Таким образом все портити превращение этого div и всего внутреннего HTML в RTE Textarea.

Извините и спасибо всем!

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...