Javascript copying itself

General questions about CMSimple
Post Reply
bwv582
Posts: 8
Joined: Wed Jan 28, 2009 12:59 am

Javascript copying itself

Post by bwv582 » Wed Jan 28, 2009 1:15 am

I'm very new to CMSimple and content management systems in general. Things have gone pretty well until I started messing with Javascript on the page. I'm trying to get a line of script to work. The script simply calls some code on an external site and writes the result back to the page. It works fine the first time, but then, since html has been written back to the document, if I edit and then resave the page using the default editor, the script gets called again and writes a second copy, etc.

I have been working for a few hours to try to figure out how to stop it from doing this. Can someone help?

ZiPs
Posts: 633
Joined: Thu May 22, 2008 6:17 pm
Location: Faxe, Denmark
Contact:

Re: Javascript copying itself

Post by ZiPs » Wed Jan 28, 2009 1:23 am

Hi bwv582

Which script is it, an du you have a link to you page, perhaps it can help to se it.

/ZiPs
Preben Dahl | Webmaster cmsimple.dk | Projekt-og domæne ejer Gert Ebersbach

bwv582
Posts: 8
Joined: Wed Jan 28, 2009 12:59 am

Re: Javascript copying itself

Post by bwv582 » Wed Jan 28, 2009 1:50 am

Sure. I'm working on a website for a church. On the old site (static pages manually maintained), there was a line of script that would pull a Bible verse from http://www.biblegateway.com and display it. The line looked like this:

Code: Select all

<script type="text/javascript" language="JavaScript" src="http://www.biblegateway.com/usage/votd/votd2html.php?version=31&jscript=1">
</script>
I added this line to my CMSimple page, and it returns a chunk of HTML which is written to the page. That's fine, the first time. The trouble is, that HTML is now part of the page, so if I edit something else on the page and resave it, the javascript runs again and another chunk of HTML is added.

Do I have to rewrite this Javascript somehow using CMSimple scripting? That's my guess. But like I said, I'm totally new to this. Or maybe, since it looks like the script line just calls some php, I don't need to use Javascript at all to get the desired result.

ZiPs
Posts: 633
Joined: Thu May 22, 2008 6:17 pm
Location: Faxe, Denmark
Contact:

Re: Javascript copying itself

Post by ZiPs » Wed Jan 28, 2009 2:16 am

Look at installersmanual http://www.cmsimple.com/...CMSimple_Scripting maybe you can use Insert from php file to du the job like this.

Code: Select all

#CMSimple $output= preg_replace("/".chr(35)."CMSimple.*".chr(35)."/",
geturl('http://www.biblegateway.com/usage/votd/votd2html.php?version=31&jscript=1'),$c[$s]);#
/ZiPs
Preben Dahl | Webmaster cmsimple.dk | Projekt-og domæne ejer Gert Ebersbach

bwv582
Posts: 8
Joined: Wed Jan 28, 2009 12:59 am

Re: Javascript copying itself

Post by bwv582 » Wed Jan 28, 2009 3:09 am

Yes! Thank you! That did it. I also had to change the end of the url to jscript=0 so it wouldn't return javascript commands as part of the html. It works.

Post Reply