Php 编码器点火器中的断路器
我想在CodeIgniter中加载CKEditor,我搜索了很多,但无法理解他们的方式 我把ckeditor放在application/plugins文件夹中,现在我想制作编辑器,所以我在Controller方法中执行以下操作Php 编码器点火器中的断路器,php,javascript,codeigniter,ckeditor,Php,Javascript,Codeigniter,Ckeditor,我想在CodeIgniter中加载CKEditor,我搜索了很多,但无法理解他们的方式 我把ckeditor放在application/plugins文件夹中,现在我想制作编辑器,所以我在Controller方法中执行以下操作 include APPPATH.'plugins/ckeditor/ckeditor.php'; $CKEditor = new CKEditor(); $CKEditor->basePath = '/'.APPPATH.'plugins/ckeditor/'; $
include APPPATH.'plugins/ckeditor/ckeditor.php';
$CKEditor = new CKEditor();
$CKEditor->basePath = '/'.APPPATH.'plugins/ckeditor/';
$initialValue = '<p>This is some <strong>sample text</strong>.</p>';
echo $CKEditor->editor("editor1", $initialValue);
包括APPPATH.plugins/ckeditor/ckeditor.php';
$CKEditor=新的CKEditor();
$CKEditor->basePath='/'.APPPATH.'plugins/CKEditor/';
$initialValue='这是一些示例文本;
echo$CKEditor->editor(“editor1”,$initialValue);
但它只制作简单的teaxaria,带有这是一些示例文本
值。
问题在哪里?我应该如何解决它?我使用以下步骤将ckeditor添加到我的codeigniter应用程序中: 1) 下载以下文件:
- 这适用于Ckeditor:
- 这适用于Ckfinder:
echo $this->ckeditor->editor("textarea name","default textarea value");
否则,您可以这样做:
<script src="<?php echo base_url(); ?>ckeditor/ckeditor.js"></script>
<link rel="stylesheet" href="<?php base_url(); ?>style/format.css">
好吧,我知道这个问题很老了,但这是我做的,似乎对我来说是最简单的
在我的根目录中,有一个名为“js”的目录,其中有一个
名为“plugins”的目录。我在那里复制了ckeditor文件
然后在application/views/common/headers
目录中,我有一个头文件
标题为“ckeditor.php
”。此文件中仅包含以下代码:
然后在控制器中,我将头文件添加到$data对象中,以传递到视图:
$data['header_files']=array('header1','header2','header3','ckeditor');//为了我的客户端,头文件名被更改了
然后,将的$data对象传递给视图,当然:
$this->load->view('common/admin模板',$data)代码>
然后我就调用了CKEDITOR.replace('textareaNameHere')李>
瞧。它有效我在这里找到了一个非常简单的两行代码解释:
以防链接消失,我将粘贴在这里的文本。这在2014年8月1日对我起了作用:
在要使用ckeditor的视图中包括此行,并将ckeditor文件夹放在根文件夹中。这里我把它放在js/ckeditor/根文件夹中
<script type="text/javascript" src="<?php echo base_url();?>js/ckeditor/ckeditor.js"></script>
同样的问题是我正在处理一件小事,你需要根文件夹中资产文件夹中的所有文件。
我的控制器部分是
$this->load->library('ckeditor');
$this->load->library('ckfinder');
$this->ckeditor->basePath = base_url().'assets/admin/ckeditor/';
$this->ckeditor->config['toolbar'] = array(
array( 'Source', '-', 'Bold', 'Italic', 'Underline', '-','Cut','Copy','Paste','PasteText','PasteFromWord','-','Undo','Redo','-','NumberedList','BulletedList' )
);
$this->ckeditor->config['language'] = 'en';
$this->ckeditor->config['width'] = '730px';
$this->ckeditor->config['height'] = '300px';
//Add Ckfinder to Ckeditor
$this->ckfinder->SetupCKEditor($this->ckeditor,base_url().'asset/admin/ckfinder/');
我的观点是
<div class="form-group">
<label for="description">Description</label> <?php echo form_error('event_description'); ?>
<?php echo $this->ckeditor->editor("event_description",((isset($event_description)) ? $event_description : ''));?>
</div>
描述
我将ck editer文件夹放在资产文件夹中,将资产文件夹放在根文件中
像
C:\wamp\www\site\assets\admin\ckeditor
从下载CKEditor包
在首选位置解压Codeigniter项目文件夹中的文件夹
在页面中包含
元素加载编辑器
使用CKEDITOR.replace()
方法将现有的
元素替换为CKEDITOR
请参见以下示例:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>A Simple Page with CKEditor</title>
<!-- Make sure the path to CKEditor is correct. -->
<script src="../ckeditor.js"></script>
</head>
<body>
<form>
<textarea name="editor1" id="editor1" rows="10" cols="80">
This is my textarea to be replaced with CKEditor.
</textarea>
<script>
// Replace the <textarea id="editor1"> with a CKEditor
// instance, using default configuration.
CKEDITOR.replace( 'editor1' );
</script>
</form>
</body>
</html>
带有编辑器的简单页面
这是要用CKEditor替换的我的文本区域。
//用一个编辑器替换
//实例,使用默认配置。
CKEDITOR.replace('editor1');
我认为使用Ckeditor最简单的方法是通过CDN,在视图文件中使用它,然后
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>CKEditor</title>
<script src="https://cdn.ckeditor.com/ckeditor5/18.0.0/classic/ckeditor.js"></script>
</head>
<body>
<textarea name="editor" id="editor" rows="10" cols="80" placeholder="Insert text here" class="form-control"></textarea>
<script>
ClassicEditor
.create( document.querySelector( '#editor' ) )
.then( editor => {
console.log( editor );
} )
.catch( error => {
console.error( error );
} );
</script>
</body>
</html>
编辑
分类编辑器
.create(document.querySelector('#editor'))
.然后(编辑=>{
console.log(编辑器);
} )
.catch(错误=>{
控制台错误(error);
} );
有关ckeditor的更多信息和样式以及不同样式ckeditor的使用,您可以访问
如果您正在寻找Ckeditor的文档编辑器,请点击以下链接
使用该示例,您将能够在视图文件中插入文档编辑器如何添加图像上载功能?在$config['toolbar']中添加了图像,但它不工作。请help@user1149244是的,你必须创建它@Mansoorkhan Cherupuzha:我发现这个链接对我在CKeditor中上传图像很有帮助。你可能想试试看。到目前为止,这是我找到的最好的教程之一。使用列出的步骤可以完美地工作!我已经按照你们的步骤,但我面临的问题是,每当我点击浏览服务器按钮,弹出屏幕显示我空白。你能帮我吗?这是一个答案,还是一个新问题?这是上述问题的答案谢谢,更简单,不可能
<script src="<?php echo base_url(); ?>ckeditor/ckeditor.js"></script>
<link rel="stylesheet" href="<?php base_url(); ?>style/format.css">
$this->load->library('ckeditor');
$this->load->library('ckfinder');
$this->ckeditor->basePath = base_url().'assets/admin/ckeditor/';
$this->ckeditor->config['toolbar'] = array(
array( 'Source', '-', 'Bold', 'Italic', 'Underline', '-','Cut','Copy','Paste','PasteText','PasteFromWord','-','Undo','Redo','-','NumberedList','BulletedList' )
);
$this->ckeditor->config['language'] = 'en';
$this->ckeditor->config['width'] = '730px';
$this->ckeditor->config['height'] = '300px';
//Add Ckfinder to Ckeditor
$this->ckfinder->SetupCKEditor($this->ckeditor,base_url().'asset/admin/ckfinder/');
<div class="form-group">
<label for="description">Description</label> <?php echo form_error('event_description'); ?>
<?php echo $this->ckeditor->editor("event_description",((isset($event_description)) ? $event_description : ''));?>
</div>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>A Simple Page with CKEditor</title>
<!-- Make sure the path to CKEditor is correct. -->
<script src="../ckeditor.js"></script>
</head>
<body>
<form>
<textarea name="editor1" id="editor1" rows="10" cols="80">
This is my textarea to be replaced with CKEditor.
</textarea>
<script>
// Replace the <textarea id="editor1"> with a CKEditor
// instance, using default configuration.
CKEDITOR.replace( 'editor1' );
</script>
</form>
</body>
</html>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>CKEditor</title>
<script src="https://cdn.ckeditor.com/ckeditor5/18.0.0/classic/ckeditor.js"></script>
</head>
<body>
<textarea name="editor" id="editor" rows="10" cols="80" placeholder="Insert text here" class="form-control"></textarea>
<script>
ClassicEditor
.create( document.querySelector( '#editor' ) )
.then( editor => {
console.log( editor );
} )
.catch( error => {
console.error( error );
} );
</script>
</body>
</html>