我是Yii框架的新手, 我的CMS管理页面需要一个FCK编辑器。我将FCKeditor下载并解压缩到yii扩展文件夹中的根文件夹及其扩展名。我在我的视图中添加了以下代码
<?php $this->widget('application.extensions.fckeditor.FCKEditorWidget',array(
"model"=>$model, # Data-Model
"attribute"=>'content', # Attribute in the Data-Model
"height"=>'400px',
"width"=>'100%',
"toolbarSet"=>'Basic', # EXISTING(!) Toolbar (see: fckeditor.js)
"fckeditor"=>Yii::app()->basePath."/../fckeditor/fckeditor.php",
# Path to fckeditor.php
"fckBasePath"=>Yii::app()->baseUrl."/fckeditor/",
# Realtive Path to the Editor (from Web-Root)
"config" => array(
"EditorAreaCSS"=>Yii::app()->baseUrl.'/css/index.css',),
# http://docs.fckeditor.net/FCKeditor_2.x/Developers_Guide/Configuration/Configuration_Options
# Additional Parameter (Can't configure a Toolbar dynamicly)
) ); ?>
这些都很好。
但编辑器是分开显示的。我需要编辑器代替内容textarea。
答案 0 :(得分:1)
<?php echo CHtml::activeTextArea($model,'content',array('rows'=>6, 'cols'=>50)); ?>
要使用FCKEditor而不是上面的textarea,请通过将以上代码替换为以下来调用集成小部件:
<?php $this->widget('application.extensions.fckeditor.FCKEditorWidget',array(
'model' => $model,
'attribute' => 'content',
'height' => '600px',
'width' => '100%',
'fckeditor' => dirname(Yii::app()->basePath).'/htdocs/fckeditor/fckeditor.php',
'fckBasePath' => Yii::app()->baseUrl.'/fckeditor/')
); ?>
你做过这样的事情,如果你这样做,那么textarea将被编辑取代,希望有所帮助