照着yiicms做,不成功。firebug提示:
finder.Popup is not a function
finder.Popup()
但是yiicms却是能用的。
相关代码
初始化ckfinder的js
$(document).ready(function(){
//ckfinder初始化ckediter
$("textarea[fmt='fck']").each(function(i){
var editor = CKEDITOR.replace( $(this).attr('id') )
CKFinder.setupCKEditor( editor, '/cms/ckfinder/' )
})
$("#browseServer").bind("click", function(){
var finder = new CKFinder('/cms/ckfinder/')
finder.SelectFunction = SetFileField
finder.Popup()
})
})
function SetFileField(fileUrl) {
$('#imgpath').val(fileUrl)
}
viewsz中的代码片段:
<div class="row">
<?php echo $form->labelEx($model,'imgpath')?>
<?php echo $form->textField($model,'imgpath',array('size'=>60,'maxlength'=>200,'id'=>'imgpath'))?>
<input type="button" id="browseServer" value="上传图片"/>
<?php echo $form->error($model,'imgpath')?>
</div>
点击“上传图片按钮”,firebug就提示错误。我在
var finder = new CKFinder('/cms/ckfinder/')
这句下面加上
alert(finder.toString())
能打印出[Object Object],说明ckfinder是初始化成功的。
1,将ckeditor解压打开,打开_Samples,将ckeditor文件夹拷贝项目中的根目录下,把bin放在根目录下2,将ckfinder解压,ckfinder文件夹拷贝项目中的根目录下,把bin放在根目录下,把_sample,_source,help文件夹删除掉,(注:没有用)
3,在ckeditor文件下找到config.js 打开,找到
在CKEDITOR.editorCongig=function(config)
{
//填写以下内容,图片,flash路径
config.uiColor = '#F7F8F9'
config.scayt_autoStartup = false
config.language = 'zh-cn'//中文
config.filebrowserBrowseUrl = 'ckfinder/ckfinder.html'
config.filebrowserImageBrowseUrl = 'ckfinder/ckfinder.html?Type=Images'
config.filebrowserFlashBrowseUrl = 'ckfinder/ckfinder.html?Type=Flash'
config.filebrowserUploadUrl = 'ckfinder/core/connector/aspx/connector.aspx?command=QuickUpload&type=Files'
config.filebrowserImageUploadUrl = 'ckfinder/core/connector/aspx/connector.aspx?command=QuickUpload&type=Images'
config.filebrowserFlashUploadUrl = 'ckfinder/core/connector/aspx/connector.aspx?command=QuickUpload&type=Flash'
};
4,在ckfinder文件下找到config.ascx文件,打开
1)把public overrider bool ChekcAuthentication(){return false改为:return true}
2)public overrider void SetConfig(){BaseUrl = "~/ckfinder/userfiles/"}
5,在页面中head标签内写入:
<script type="text/javascript" src="ckeditor/ckeditor.js" ></script>
<script type="text/javascript" src="ckfinder/ckfinder.js"></script>
如果有母版页,在母版页中写
--注:单纯的配置,6,7可以不要,但是一旦要入数据库中,就要配置6.7步骤
6,在Default.aspx页面中,写入<%@Page ValidateRequest="false"%>
7,在web.config文件中,在system.web下写 <httpRuntime requestValidationMode="2.0"/>
8,在Default.aspx页面中添加<asp:TextBox ID="txtcontent" runat="server" TextMode="MultiLine" Height="503px" Width="100%" class="ckeditor" ></asp:TextBox>
<script type="text/javascript">
CKEDITOR.replace('<%= txtcontent.ClientID %>', { skin: 'kama' })
</script>(用ckfinder文件下skins文件下kama文件下的,skin.js,样式)