What's New?

05:02 AM Lop hoc SEO mien phi

video

lenamdang lenamdang Author
Title: Bài 8: Sử dụng CKEditor để soạn thảo trong PHP
Author: lenamdang
Rating 5 of 5 Des:
Việc soạn thảo trong PHP là 1 kĩ thuật hết sức quan trọng. Vì vậy hôm nay hocweb.com.vn sẽ giúp các bạn sử dụng kĩ thuật CKEditor để soạn ...
Việc soạn thảo trong PHP là 1 kĩ thuật hết sức quan trọng. Vì vậy hôm nay hocweb.com.vn sẽ giúp các bạn sử dụng kĩ thuật CKEditor để soạn thảo trong PHP này 1 cách chi tiết
Đầu tiên ta download CKEditor ở trang web sau ckeditor.com
Giao diện trang web download như sau:
download ckeditor Bài 8: Sử dụng CKEditor để soạn thảo trong PHP

Sau khi download xong ta giải nén source ckeditor và copy vào htdocs/folder chứa web. Để chạy được source này ta test ví dụ sau do ckeditor đã hỗ trợ (file _posteddata.php) có trong source đã download về. Ta cũng chép file này vào thư mục gốc. Nội dung file này như sau:
Ta bắt đầu test hoạt động của CKeditor bằng 2 cách:
 Cách 1:  dùng CKEDITOR.replace(‘nameofcontrol’); (dùng Ajax để show ckeditor)
Cụ thể ta làm giao diện sau:
giao dien cach 1 Bài 8: Sử dụng CKEditor để soạn thảo trong PHP
Code HTML của giao diện này như sau:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Untitled Document</title>
<script type="text/javascript" src="ckeditor/ckeditor.js"></script>
</head>

<body>
<form action="_posteddata.php" method="post">
<textarea name="tomtat" cols="" rows="" ></textarea>
<script type="text/javascript">
            //<![CDATA[

                // This call can be placed at any point after the
                // <textarea>, or inside a <head><script> in a
                // window.onload event handler.

                // Replace the <textarea id="editor"> with an CKEditor
                // instance, using default configurations.
                CKEDITOR.replace( 'tomtat' );
                

            //]]>
            </script>
            <input name="ok" type="submit" value="Ok" />
</form>
</body>
</html>



 Cách 2: Dùng PHP
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Untitled Document</title>
<script type="text/javascript" src="ckeditor/ckeditor.js"></script>
</head>

<body>
<form action="" method="post"><textarea name="tomtat" cols="" rows="" ></textarea>
<textarea name="tomtat1" cols="" rows="" ></textarea>

<?php
// Include the CKEditor class.
include_once "ckeditor/ckeditor.php";

// Create a class instance.
$CKEditor = new CKEditor();

// Path to the CKEditor directory.
$CKEditor->basePath = '/ckeditor/';

// Replace a textarea element with an id (or name) of "textarea_id".
//$CKEditor->replace("tomtat");
$CKEditor->replaceall();

?>
            <input name="ok" type="submit" value="Ok" />
</form>
<?php
if(isset($_POST["tomtat"]))
echo stripslashes($_POST["tomtat"]);
if(isset($_POST["tomtat1"]))
echo $_POST["tomtat1"];
?>
</body>
</html>




 Nếu có thắc mắc về bài viết các bạn vui lòng comment bên dưới nhé. Chúc các bạn thành công.
 Xem thêm tại http://hocweb.com.vn/category/hocweb/php-mysql/php-co-ban/
----------------------------------------------------------------------------------------------------------------------------------------------------------
Nếu bạn thấy bài viết hữu ích, hãy nhấn +1 và các liên kết chia sẻ để website ngày càng phát triển hơn. Xin cám ơn bạn!
03 Dec 2013

About Author

Advertisement

No result! Or Error Loading Feed
No result! Or Error Loading Feed

Đăng nhận xét

  1. E muốn tìm hiểu cái này, nhưng e bị hổng hết kiến thức rồi. nên cũng chịu thua...:(((

    Trả lờiXóa

Emoticon
:) :)) ;(( :-) =)) ;( ;-( :d :-d @-) :p :o :>) (o) [-( :-? (p) :-s (m) 8-) :-t :-b b-( :-# =p~ $-) (b) (f) x-) (k) (h) (c) cheer
Click to see the code!
:-d

 
Top