Log in

View Full Version : how to implement text editor in basic php cms?



davelf
04-13-2010, 06:54 AM
i 'm trying to make a website base php + CMS.

What i already do:
Basic php + CMS (add, delete, edit)

Problem:
1. This is my first time developing CMS
2. I want to use this text editor in my CMS:http://www.dynamicdrive.com/dynamicindex16/richtexteditor/index.htm


This is an example of my form

addnews:


<!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>Add News</title>
<script language="javascript">
function cekform(){
//ini untuk ngecek formnya (semua form tidak boleh kosong)
if(document.frmnews.txtsubject.value==""){
alert('Subject Must be Filled');
document.frmnews.txtsubject.focus();
return false;
}
else if(document.frmnews.txtcontent.value==""){
alert('Content Must be Filled');
document.frmnews.txtcontent.focus();
return false;
}
else {
return true;
}
}
</script>
</head>

<body bgcolor="#CCCCCC">
<div align="center">
<table width="800" border="0" cellpadding="0" cellspacing="0" bgcolor="#FFFFFF">
<tr>
<td colspan="2"><?php include "header.php";?></td>
</tr>
<tr>
<td width="160" valign="top"><?php include "menu.php";?> </td>
<td width="640" align="center" valign="top">
<p><br>
<!-- Content Here -->
</p>
<form action="" method="post" name="frmnews" onsubmit="return cekform()">
<table width="500px" border="1">
<tr>
<td>Subject </td>
<td><input name="txtsubject" type="text" id="txtsubject" /></td>
</tr>
<tr>
<td>Content</td>
<td><textarea name="txtcontent" id="txtcontent" rows="20" cols="50"></textarea></td>
</tr>
<tr>
<td>&nbsp;</td>
<td><input name="tblIsi" type="submit" id="tblIsi" value="add" /></td>
</tr>
</table>

</form>
</td>
</tr>
<tr>
<td colspan="2"><?php include "footer.php";?></td>
</tr>
</table>
</div>
</body>
<?
include "connect.php";
if(isset($_POST['tblIsi'])){
$subject = $_POST['txtsubject'];
$date = date("d/m/y");
$content = $_POST['txtcontent'];
$sql="insert into news(subject,content,date) values('$subject','$content','$date')";

$kueri = mysql_query($sql);
if($kueri){
echo "<script>alert('News success insert to DB');document.location='news.php'</script>";

} else {
echo "<script>alert('News failed insert to DB')</script>";
echo mysql_error();
}
}
include("disconnect.php");
?>


This is my basic CMS form look like without text editor
http://www.dynamicdrive.com/forums/attachment.php?attachmentid=3240&stc=1&d=1271142227

thx in advanced for your attention...:)

Beverleyh
04-15-2010, 12:24 PM
So do the scripts you have work already and do the add/edit/delete part?
Do you just want help integrating the WYSIWYG editor into the form?

Please provide more info.

If not, you might want to look at this simple CMS script here: Lil CMS: http://www.lilcms.com/
It's what I keep going back to. It only performs the edit part of your requirements but you can create new files using this script: http://www.phptoys.com/e107_plugins/content/content.php?content.29

Then you could integrate TinyMCE into Lil CMS, which is a really nice WYSIWYG editor and you can pick and choose your own toolbar functions: http://tinymce.moxiecode.com/examples/full.php

Thats what I did and with a bit of CSS, I came up with this for my own uses:
http://i40.tinypic.com/3096jp3.jpg

Alternatively you could try this script: XQTO File Manager: http://www.xqto.com/filemanager.php

Hope that helps