Wait a minute now... you can't DO THAT??

Random stuff about serendipity. Discussion, Questions, Paraphernalia.
Post Reply
James

Wait a minute now... you can't DO THAT??

Post by James »

I have been using Serendipity since January now, but only now have I come across the need/desire to insert my own code IN AN ENTRY.

I have tried thus far (unsuccessfully) to embed javascript code in a new entry. At first I thought the extra <br> lines that the system seems to be adding (I tried checking the 'disable newline to br tag' option and using the textarea only input method) were screwing up the javascript interpreter.

Then I quickly tried a short PHP "hello world" test and realized from analyzing the HTML output that the PHP was not being interpretted.

This led me to believe of course that JAVASCRIPT is also not being interpreted.

Can code such as this not be imbedded in body text of an entry?

Is there maybe a setting I am forgetting about that would allow for this?

The JAVASCRIPT I was trying to get to work incidentally was the Google Maps API...

Code: Select all

<div id="map" style="width: 500px; height: 400px"></div>
    <script type="text/javascript">
    //<![CDATA[
    
    var map = new GMap(document.getElementById("map"));
    map.addControl(new GSmallMapControl());
    map.centerAndZoom(new GPoint(-122.1419, 37.4419), 4);
    
    //]]>
    </script>
Any input?
James

PS - There is another script that is needed along with this script that I originally tried in the body text as well, but then moved it to the HEAD with still no success

Code: Select all

<script src="http://maps.google.com/maps?file=api&v=1&key=AABBCCDDEEFF" type="text/javascript"></script>
James

Post by James »

Okay, I may have jumped to a conclusion. :oops:

PHP probably still doesn't work (haven't bothered to figure out how to disable the security settings in Smarty yet) but that's ok.

JAVASCRIPT apparently really does work! Yay! :o

After cleaning up the code a bit (there were some extraneous spaces, etc.) and disabling ALL markup plugins, I was able to get the code to work.

However...

Only successfully in Mozilla so far. :(

IE seems to just fail for some reason. The code example I used above is the same code that is now working in Mozilla. But not in IE.

Any specifics of Serendipity/IE/javascript combos that are known issues?

Thanks.
James

PS - It appears the "Disable NL2BR" option in the post editor does not really do what it advertises...
garvinhicking
Core Developer
Posts: 30022
Joined: Tue Sep 16, 2003 9:45 pm
Location: Cologne, Germany
Contact:

Post by garvinhicking »

You figured it out already on your own, so just to add: PHP within entries could impose a major security risk, thus it's not enabled. However there is a SMARTY markup plugin so that you can use smarty code in your entries, which in effect can wrap/access custom PHP functions via your template's config.inc.php file (read http://www.s9y.org/78.html)
PS - It appears the "Disable NL2BR" option in the post editor does not really do what it advertises...
Hm, are you maybe using the entryproperties entry caching? This could maybe interfer...

Do you have a URL where I can see the non-working JS on IE?

Regards,
Garvin
# Garvin Hicking (s9y Developer)
# Did I help you? Consider making me happy: http://wishes.garv.in/
# or use my PayPal account "paypal {at} supergarv (dot) de"
# My "other" hobby: http://flickr.garv.in/
James

Post by James »

Sure, thanks.

http://blog.jamestilberg.com/archives/212-Map-Test.html

Right now it's just the basic Google example. I figured I would try to get it to work first before adding the bells and whistles. :)

I wish there was some sort of debugging output from IE but there doesn't seem to be. As mentioned, the above link seems to work in Mozilla...

James
James

Post by James »

Garvin,

This discussion is directly related to Rob's plugin being discussed in plugins.

http://www.s9y.org/forums/viewtopic.php?t=2133

I'm going to comment further over there...

James
Post Reply