Recent Widgets


Register for DashboardWidgets

Recent Forums Posts

Partners


iCompositions

MacDesktops.net

RSS Showcase
RSS Comments
RSS Forums

This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies. Posted in: Widget Development

Bringing in a php file

Author Message
johnkrutsch



Joined: 15 Sep 2008
Posts: 2

Posted: Mon Sep 15, 2008 - 7:11 pm    Post subject: Bringing in a php file Reply with quote

I have made a widget which works fine in browsers but when I try it as a widget in dashboard it only displays my default image not the data I want it to display. I have experimented with several plist keys but none of them have worked. My php file lives out on the internet and does all of the work i.e. massages all of the data into the needed format then passes the data in as a js variable.

here is the js/php part:
Code:

<script type="text/javascript" src="http://metasolutions.us/cpoll.php"></script>
<div id="content">
<script type="text/javascript">
   document.write(str);
</script>


the rest of my html page is just css. to see it in a browser go to:http://metasolutions.us/cpoll.html

Any ideas why I can't bring in the data from cpoll.php?
View user's profile Send private message Send e-mail Widgets
johnkrutsch



Joined: 15 Sep 2008
Posts: 2

Posted: Tue Sep 16, 2008 - 10:37 am    Post subject: Reply with quote

Ok instead of bringing the php generated code as a JavaScript variable I am attempting to bring it in with widget.system. I have ensured that that I have the proper plist key for AllowSystem and I have even altered my html to test the use of this type of method with ajax.

When I open a terminal window and type in:
Code:

/usr/bin/curl http://metasolutions.us/cpoll.php

I get the expected results, i.e. the generated code is displayed. When I do it in my widget with:
Code:

widget.system("/usr/bin/curl http://metasolutions.us/cpoll.php",null).outputString


nothing happens. What am I missing? How do you debug widgets? I have read and tinkered for hours on end. I simply want to display what my php page generates.
View user's profile Send private message Send e-mail Widgets
thewilson



Joined: 28 Aug 2008
Posts: 18

Posted: Fri Sep 19, 2008 - 9:10 pm    Post subject: Reply with quote

I would suggest you visit http://www.w3schools.com and go through the javascript and php tutorials found there. These will give you a fuller understanding of the languages you are attempting to use. It would appear your most immediate solution would be to use the web clips functionality introduced in Safari 3.

If you arent down for that and want to code it out lets figure out our options.

with the widget system call you are able to save the stdout output of a commandline utility to a variable.

with an iframe you get a browser window that you can style and modify with javascript and put it in a div too if you like Very Happy

Thats my opinion i would do something like
JS
Code:
/* For CSS Styles you can do something like this */
document.getElementById("Content").style.<propertyname> = <property value>;
/* To change the iframe source its just */
document.getElementById("pageData").src = <full url>

HTML
Code:
<div id='Content'>
<iframe id="pageData" src="http://metasolutions.us/cpoll.php">
</div>


There are a few other things i want to get out before i fall asleep for bed time

1. PHP is a server side language and must be interpreted. If you want to view the results you need to get the output not the source file. You can run php through the php interpreter if you have it installed on your computer.

2. JavaScript is a client side language and is interpreted by the browser. It doesn't do things like file manipulation or database queries usually.

3. If you download xcode it comes with some awesome tools for building widgets check it out you'll be amazed
View user's profile Send private message Send e-mail Widgets
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.

 
Powered by phpBB © 2001, 2002 phpBB Group