Reputation: 4078
how to add or embed CKEditor in php page, I downloaded and extracted the zip file into root of the directory and also called on my page
<?php require("ckeditor/ckeditor.php"); ?>
gave the textarea this fields
<textarea class="ckeditor" name="editor1">Write any thing</textarea>
But its not working, Documentation for installation on PHP is not found CKEditor website.
Does any one knows where we or help me out..for this app.
Upvotes: 10
Views: 122313
Reputation: 10025
After reading the Quick Start Guide
In your HTML page add an element that CKEditor should replace:
<textarea name="content" id="editor"></textarea>
Load the classic editor build (here CDN location is used):
<script src="https://cdn.ckeditor.com/ckeditor5/10.0.1/classic/ckeditor.js"></script>
Call the ClassicEditor.create() method.
<script>
ClassicEditor
.create( document.querySelector( '#editor' ) )
.catch( error => {
console.error( error );
} );
</script>
Example
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>CKEditor 5 - Classic editor</title>
<script src="https://cdn.ckeditor.com/ckeditor5/10.0.1/classic/ckeditor.js"></script>
</head>
<body>
<h1>Classic editor</h1>
<textarea name="content" id="editor">
<p>This is some sample content.</p>
</textarea>
<script>
ClassicEditor
.create( document.querySelector( '#editor' ) )
.catch( error => {
console.error( error );
} );
</script>
</body>
</html>
This example is for the specific classic editor. FOr other variants, only CDN will change.
Upvotes: 2
Reputation: 1285
If you have downloaded the latest Version 4.3.4 then just follow these steps.
Load the mentioned js file
<script type="text/javascript" src="/ckeditor/ckeditor.js"></script> <textarea class="ckeditor" name="editor"></textarea>
Upvotes: 16
Reputation: 75
Alternately, it could also be done as:
<?php
include("ckeditor/ckeditor.php");
$CKeditor = new CKeditor();
$CKeditor->BasePath = 'ckeditor/';
$CKeditor->editor('editor1');
?>
Note that the last line is having 'editor1' as name, it could be changed as per your requirement.
Upvotes: 4
Reputation: 31
<?php require("ckeditor/ckeditor.php"); ?>
<script type="text/javascript" src="ckeditor/ckeditor.js"></script>
<script type="text/javascript" src="somedirectory/ckeditor/ckeditor.js"></script>
<textarea class="ckeditor" name="editor1"></textarea>
Upvotes: 3
Reputation: 766
Easy steps to Integrate ckeditor with php pages
step 1 : download the ckeditor.zip file
step 2 : paste ckeditor.zip file on root directory of the site or you can paste it where the files are (i did this one )
step 3 : extract the ckeditor.zip file
step 4 : open the desired php page you want to integrate with here page1.php
step 5 : add some javascript first below, this is to call elements of ckeditor and styling and css without this you will only a blank textarea
<script type="text/javascript" src="ckeditor/ckeditor.js"></script>
And if you are using in other sites, then use relative links for that here is one below
<script type="text/javascript" src="somedirectory/ckeditor/ckeditor.js"></script>
step 6 : now!, you need to call the work code of ckeditor on your page page1.php below is how you call it
<?php
// Make sure you are using a correct path here.
include_once 'ckeditor/ckeditor.php';
$ckeditor = new CKEditor();
$ckeditor->basePath = '/ckeditor/';
$ckeditor->config['filebrowserBrowseUrl'] = '/ckfinder/ckfinder.html';
$ckeditor->config['filebrowserImageBrowseUrl'] = '/ckfinder/ckfinder.html?type=Images';
$ckeditor->config['filebrowserFlashBrowseUrl'] = '/ckfinder/ckfinder.html?type=Flash';
$ckeditor->config['filebrowserUploadUrl'] = '/ckfinder/core/connector/php/connector.php?command=QuickUpload&type=Files';
$ckeditor->config['filebrowserImageUploadUrl'] = '/ckfinder/core/connector/php/connector.php?command=QuickUpload&type=Images';
$ckeditor->config['filebrowserFlashUploadUrl'] = '/ckfinder/core/connector/php/connector.php?command=QuickUpload&type=Flash';
$ckeditor->editor('CKEditor1');
?>
step 7 : what ever you name you want, you can name to it ckeditor by changing the step 6 code last line
$ckeditor->editor('mycustomname');
step 8 : Open-up the page1.php, see it, use it, share it and Enjoy because we all love Open Source.
Thanks
Upvotes: 26
Reputation: 1801
no need to require the ckeditor.php, because CKEditor will not processed by PHP...
you need just following the _samples directory and see what they do.
just need to include ckeditor.js by html tag, and do some configuration in javascript.
Upvotes: 3