2012-05-08 90 views
2

我是Yii框架的新手, 我需要一个FCK编辑器来管理我的CMS管理页面。我下载并提取了FCKeditor到yii扩展文件夹中的根文件夹及其扩展名。并在我看来添加了以下代码如何在Yii中设置FCK编辑器?

<?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。 enter image description here

+2

每次我看到FCK编辑器我认为它说别的... – goat

回答

1
<?php echo CHtml::activeTextArea($model,'content',array('rows'=>6, 'cols'=>50)); ?> 

要使用方法FCKeditor来代替上述文本区域,通过更换上面的代码与下面调用集成小部件

<?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将被替换为编辑器,希望有帮助

+0

是的,这是行得通...感谢Sudhir。我遵循jquery模型替换,这是重复..谢谢 – nu6A