karl - Fri, Oct 18th - 2002
How-To: Loading Content
As of version 0.5, loading content into the editor is fairly simple.
[b:17194d6a13]A sample in ASP and PHP can be downloaded from the downloads section: http://openmymind.net/download.php?search=ewe_sample[/b:17194d6a13]
The load() method has one required and one optional argument. The required argument is the container to load the editor into. The second argument is the content to place within the editor. For example:
[code:1:17194d6a13]
function onLoad(){
//Load an empty editor
var ewe = new EWE();
ewe.load(document.all.eweContainer);
//load a simple message into the editor
var ewe = new EWE();
ewe.load(document.all.eweContainer, '<b>Hello World</b>');
//dumps an ASP variable into the content
var ewe = new EWE();
ewe.load(document.all.eweContainer, '<%=ddbContent%>');
}
[/code:1:17194d6a13]
The last method _will_ break the edito if the variable contains any single quotes. An example:
[code:1:17194d6a13]
<?php
$ddbContent = "How's it going?";
?>
<script language="jscript">
function onLoad(){
var ewe = new EWE();
ewe.load(document.all.eweContainer, '<?=$ddbContent?>');
//the above line will become this:
//ewe.load(document.all.eweContainer, 'How's it going?');
}
</script>
[/code:1:17194d6a13]
It should be obvious that the above code will break. [b:17194d6a13]'How's it going[/b:17194d6a13] is an invalid string.
To resolve the problem, create a hidden <div></div> tag, dump the variable content into it, and pass the div tag to the load function.
[code:1:17194d6a13]
<?php
$ddbContent = "How's it going?";
?>
function onLoad(){
var ewe = new EWE();
ewe.load(document.all.eweContainer, document.all.hiddenContent.innerHTML);
}
...
...
//somewhere in your html
<div id="hiddenContent" style="height:1px;width:1px;overflow:hidden;position:absolute;visibility:hidden"><?=ddbContent?></div>
[/code:1:17194d6a13]
Hope that helps!
Karl
chemanfit - Mon, Oct 21st - 2002
how about slashes
depending on how you are using it, you could also add slashes. I pull the data from a database and therefore it is already has addslashes() performed on it.
For instance:
How\'s it going.
karl - Mon, Oct 21st - 2002
yup..but that's only true for some databases. MS SQL expects single quotes to be escaped by another single quote:
[color=darkred:fbd55670f8][b:fbd55670f8]how''s it going?[/b:fbd55670f8][/color:fbd55670f8]
which will still bust how EWE loads a string..but using ASP you could then replace all single quotes with \' and double quotes with \" which I guess would work.
Whichever alternative works best.
Karl
tecONE - Tue, Oct 22nd - 2002
I tried this:
[code:1:ceab16587e]<?php
$ddbContent = "Hows it going?";
?>
<script language="JScript">
var ewe = new EWE();
ewe.load(document.all.eweContainer, '<?=ddbContent?>');
</script>[/code:1:ceab16587e]
but it doesn't work....
karl - Tue, Oct 22nd - 2002
Techone..my examples are probably not very good. I'll correct them...
but for now, there were two mistakes in them :)
First, I was missing the $ for the variable...ala: <?=$ddbContent?>.
Secondly, the
var ewe = new EWE();
ewe.load(document.all.eweContainer, '<%=ddbContent%>');
is supposed to be in the onLoad() function.
The examples above should be corrected by the time you see this...
tecONE - Tue, Oct 22nd - 2002
thank you very much karl...
I'll try it immediately
tecONE - Tue, Oct 22nd - 2002
sorry, I'm new in Jscript
[code:1:d57b6bafc7]<script language="JScript">
function onLoad(){
//Load an empty editor
//load a simple message into the editor
var ewe = new EWE();
ewe.load(document.all.eweContainer, '<b>Hello World</b>');
}
</script>[/code:1:d57b6bafc7]
is this right?
karl - Tue, Oct 22nd - 2002
yup...that worked for me.
tecONE - Tue, Oct 22nd - 2002
?? it work???
why not at me??
load.php:
[code:1:65c3df9d42] <script language="JScript">
function onLoad(){
//Load an empty editor
//load a simple message into the editor
var ewe = new EWE();
ewe.load(document.all.eweContainer, '<b>Hello World</b>');
}
[/code:1:65c3df9d42]
and then run load.php
LOADING ERROR??? - Mon, Oct 28th - 2002
here is the function i am using to pull content from the HTMLContent field:
function onLoad(){
var ewe = new EWE();
ewe.load(document.all.eweContainer, '<cfoutput query='load'>#HTMLContent#</cfoutput>');
when i add tables or spaces i get this error:
function onLoad(){
var ewe = new EWE();
ewe.load(document.all.eweContainer, '[b:d6068c6655]<TABLE cellSpacing=2 cellPadding=2 align=0 border=2>
<TBODY>
<TR>
<td> </TD>
<td> </TD></TR>
<TR>
<td> </TD>
<td> </TD></TR></TBODY></TABLE>'); [/b:d6068c6655]
do you know why this is happening... the error is causing nothing to show up in the editor...
it works when i just type in information without adding spaces or tables. so everything with the database is in tact. it just gets messed up once tables or <P> are added
tecONE(not logged in) - Mon, Oct 28th - 2002
I found a way, to load and save data from an mySQL Database.
In the Database there are a lot of html pages and it's no problem to load them.
I will prepare a zip if you want which contains all modified scripts
Anonymous - Mon, Oct 28th - 2002
LOADING CONTENT
THAT WOULD BE GREAT!!! SEND IT ON OVER TO GAVIN@GAVINVINCENT.COM.....
THANKS A LOT!!
Anonymous - Mon, Oct 28th - 2002
LOADING CONTENT
i figured it out with the div tags above.. thanks anyways though :)
WMU - Thu, Oct 31st - 2002
Please send it to me....
techOne can you please also send to this e-mail rtjahaja@hotmail.com
Thanks....
goaboy - Thu, Nov 14th - 2002
JS-Error when I load the content with php into the editor
Hello,
I just tried the php-part, it worked withe a standard "echo", but when I load a contnet from a database I get an Javascript-Error...
Here is my source:
<head>
<?php
$db = mysql_connect("localhost", "","");
mysql_select_db("test",$db);
$sql = "SELECT * FROM inhalt where nummer=777";
$result = mysql_query($sql,$db);
$data = mysql_fetch_array($result);
$HTMLContent = $data[beschreibung];
?>
<script language="JavaScript" src="source/ewe.js">
</script>
<script language="jscript">
function go(){
var ewe = new EWE();
ewe.load(document.all.eweContainer, '<?php echo $HTMLContent;?>');
}
</script>
</head
<body unselectable="on" bgcolor="#FFFFFF" onLoad="go();" onKeyDown="dispatcher();">
<div id="eweContainer" unselectable="on"></div>
Has anyone the same problem, or is it a syntax error in the php?
Thank U
goaboy
goaboy - Thu, Nov 14th - 2002
Re: JS-Error when I load the content with php into the edito
[quote:897c3994ae="goaboy"]Hello,
I just tried the php-part, it worked withe a standard "echo", but when I load a contnet from a database I get an Javascript-Error...
Here is my source:
<head>
<?php
$db = mysql_connect("localhost", "","");
mysql_select_db("test",$db);
$sql = "SELECT * FROM inhalt where nummer=777";
$result = mysql_query($sql,$db);
$data = mysql_fetch_array($result);
$HTMLContent = $data[beschreibung];
?>
<script language="JavaScript" src="source/ewe.js">
</script>
<script language="jscript">
function go(){
var ewe = new EWE();
ewe.load(document.all.eweContainer, '<?php echo $HTMLContent;?>');
}
</script>
</head>
<body unselectable="on" bgcolor="#FFFFFF" onLoad="go();" onKeyDown="dispatcher();">
<div id="eweContainer" unselectable="on"></div>
Has anyone the same problem, or is it a syntax error in the php?
Thank U
goaboy[/quote:897c3994ae]
gg - Thu, Nov 14th - 2002
Re: JS-Error when I load the content with php into the edito
[quote:5aa4081366="goaboy"]Hello,
I just tried the php-part, it worked withe a standard "echo", but when I load a contnet from a database I get an Javascript-Error...
Here is my source:
<head>
<?php
$db = mysql_connect("localhost", "","");
mysql_select_db("test",$db);
$sql = "SELECT * FROM inhalt where nummer=777";
$result = mysql_query($sql,$db);
$data = mysql_fetch_array($result);
$HTMLContent = $data[beschreibung];
?>
<script language="JavaScript" src="source/ewe.js">
</script>
<script language="jscript">
function go(){
var ewe = new EWE();
ewe.load(document.all.eweContainer, '<?php echo $HTMLContent;?>');
}
</script>
</head>
<body unselectable="on" bgcolor="#FFFFFF" onLoad="go();" onKeyDown="dispatcher();">
<div id="eweContainer" unselectable="on"></div>
Has anyone the same problem, or is it a syntax error in the php?
Thank U
goaboy[/quote:5aa4081366]
chemanfit - Thu, Nov 14th - 2002
I would suggest using the hidden div technique to load content into the ewe, there are a few postings as to how to do this. It is possible that you have a ' in the content that you are loading and this would cause the load to fail because it would close the statement too early and leave extra stuff for the browser to figure out what to do with.
I have had much success with the hidden div's so give it a try. Just echo into the hidden div. I would also suggest using a different variable for the php side of the loading, dont know if that would cause a problem or not.
karl - Thu, Nov 14th - 2002
The hidden div trick will solve your problem. I've explained how to do it more than once, you shouldn't have any problems doing it.
karl
goaboy - Fri, Nov 15th - 2002
Thank U, now it works fine
:o
[b:946f70b429]goboay[/b:946f70b429]
Petersen Did It - Fri, Dec 13th - 2002
The way I have been doing it is :
<HTML xmlns:move>
<head>
<title>Easy Web Editor (EWE)</title>
<? $text="ADSALDJLSAJDLASKJD";
echo"
<script language=\"JScript\">
function onLoad(){
var ewe = new EWE(null, 'sample.css');
ewe.load(document.all.eweContainer,'$text');
}
</script>
";?>
<script language="JScript" src="source/ewe.js"></script>
</head>
<body bgcolor="#FFFFFF" onLoad="onLoad();" onKeyDown="dispatcher();">
<div id="eweContainer" unselectable="on"></div>
</body>
</html>
you just have to make just you \" out all the " .
:)
Anonymous - Sun, Dec 22nd - 2002
[quote:16c90898c3="tecONE(not logged in)"]I found a way, to load and save data from an mySQL Database.
In the Database there are a lot of html pages and it's no problem to load them.
I will prepare a zip if you want which contains all modified scripts[/quote:16c90898c3]
Could you post a link / zip file or just the way you did it ? Should be realy grat :D
Anonymous - Tue, Jan 7th - 2003
[quote:2d0545c27a]I found a way, to load and save data from an mySQL Database.
In the Database there are a lot of html pages and it's no problem to load them.
I will prepare a zip if you want which contains all modified scripts
[/quote:2d0545c27a]
Yes Pleeeeeeaaaase!!! Post a link or mail it to morten@PDAnmark.dk if you would be so kind :!: :D
Petersen Did It - Tue, Jan 7th - 2003
You can just use what i posted [url]http://www.openmymind.net/forum/viewtopic.php?t=73[/url]
It works for PHP users and MYSQL.
:)
devnore - Wed, Jan 22nd - 2003
Wht's the error ??
It would help if u tell the error.....
if the php var is a array the make a loop
Anonymous - Tue, Feb 25th - 2003
how to get rolling
Hi to all.
Could some one tell me (if i am only stupid) how can I get this editor
in use.
For example I have Linux/Apache/PHP working and I have simple
index.php that has only html in content so what do I have to do
if I want to use this editor when I want to update index.php or
if I want to create new page and I want to edit both pages.
I can not get content load or save, Am I missing something???
I followed those examples in forum but result was nothing.
karl - Tue, Feb 25th - 2003
have you checked this out:
http://www.openmymind.net/download.php?cmd=view&id=8
Karl
Anonymous - Tue, Feb 25th - 2003
how to get rolling
Thank you Karl
[quote:c6c1830a7b="karl"]have you checked this out:
http://www.openmymind.net/download.php?cmd=view&id=8
Karl[/quote:c6c1830a7b]
Yes I have and I get this php mysql work easily.
But how do I have to change for example save.php or edit.php to get values directly from files index.html or index.php these file are pure html.
This part is to one that I cant get work. :oops:
Or if I have textarea on web site, how can I edit this textarea using editor.
Your editor is working very good and it has very nice outfit.
My other project is kind of cms solutation and it is php/mysql based
and there this editor work fine.
Thank you
chemanfit - Wed, Feb 26th - 2003
use the php fopen command and then I would put some sort of distinct marker to signify where to begin the editing and where to end the editing. Perhaps [edit begin here] and [edit end here] tags or something of that nature. Then just search through the file and pull the contents between the tags and edit to hearts content then replace that information with the new information. I have seen this with other editors, but unsure what they were since it has been such a long time.
Good luck!
fred - Wed, Feb 26th - 2003
if this a multiline variable youre parsing into the javascript load function this will result in an error, you'll have to str_replace the \r and \n to \\r and \\n before parsing, so the variable has no newlines and cariagereturns in the loadfunction script itself.
chemanfit - Thu, Feb 27th - 2003
would reccomend the hidden div technique to eliminate the errors in the javascript load function call.
Anonymous - Fri, Feb 28th - 2003
get it rolling
Thanks chemanfit
I was not thinking at all. First part is do and now I can open chosen content to editor. Next step is to get save.php to work right.
chemanfit - Fri, Feb 28th - 2003
glad I could help, good luck on the saving part. Don't forget that if you are using the webserver user to write directly to the file, you will need to give it the correct user permissions, especially write. You are presenting yourself with a security issue since you are giving write access to do that though. Be careful with the permissions that you set.
nakouzia - Fri, Mar 21st - 2003
how to load and save
Dear all
I don't know any scripting language to edit or modify the page
can any one help me
what I need is simple:
I want to open the editor and load an html file
edit it and save it
very simple but I really need help
please mail me @ ic2000@cyberia.net.lb
or post the reply here
thanks alot to the guy who will help me
Genlock - Thu, May 8th - 2003
it is simple
it is simple. One needs an object that line pagings interpreted.
in the HTML there is the <textarea></textarea>.
now the solution. this is vor the EWE 0.62
<script language="JScript">
function onLoad(){
var ewe = new EWE(null, '/css/css.asp');
document.getElementById("LoadContent").style.display = 'none'; //make the text textarea invisible
ewe.load(document.getElementById("eweContainer"), document.getElementById("LoadContent").value); //load textarea
}
</script>
<script language="JScript" src="/editor/source/ewe.js"></script>
<div id="eweContainer" unselectable="on"></div>
<textarea name="LoadContent" id="LoadContent" cols="3" rows="3"><%= content %></textarea> //I gaht the variable
siberian - Sun, Aug 31st - 2003
THANK YOU
I was banging my head against the wall for an hour on this one.
Thanks
tomroe - Mon, Sep 15th - 2003
Load html-document
Could someone please tell me, what should I put into function open and etc. that I can open an existing html document into editor...
Thanx