« TGIF
» Slides For My php|works Presentation “What Can PHP Learn From Ruby On Rails?”

Uncategorized

Run-up To php|works and some AJAX fun

09.12.06 | 1 Comment

Ah, only one more day of work (today) then I'm off to php|works for three days, and hopefully not embarassing myself during my talk "What Can PHP Learn From Rails". I hope to run into some people I met before and make some new friends. It's weird going to a conference where you really don't know anyone and no co-workers are coming with you. Luckily I'm not shy, so I'm sure I'll make some friends while I'm there.

I spent some time yesterday adding some code to the stats reporting system I created for work to display an animated graphic (stolen from AjaxPatterns, a site I find myself going to more and more as I expand my l33t skillz to include practical Ajax stuff). Using the Yahoo YUI, here's all the javascript code I'm using to make it happen:

PHP:
  1. <script type="text/javascript">
  2.  
  3.     // Object that handles response from XmlHttpRequest
  4.     var responseObj = {
  5.         success: function (o) {
  6.             YAHOO.util.Dom.setStyle("progress", "visibility", "hidden");
  7.             YAHOO.util.Dom.setStyle("hiddenDIV", "visibility", "visible");
  8.             response = o.responseText;
  9.             YAHOO.util.Dom.get ("hiddenDIV").innerHTML = response;
  10.         },
  11.        
  12.         failure: function (o) {
  13.             alert ("ERROR -- Could not get data for your report!");
  14.         }
  15.     }
  16.    
  17.     // process request to get page views information
  18.        
  19.     function getpageviews(field, start_date, finish_date) {
  20.         YAHOO.util.Dom.setStyle("hiddenDIV", "visibility", "hidden");
  21.         YAHOO.util.Dom.setStyle("progress", "visibility", "visible");
  22.         YAHOO.util.Connect.asyncRequest('GET', "/verticalscope_stats/reports/getpageviews/" + field + "/" + start_date + "/" + finish_date, responseObj);
  23.     }
  24.    
  25.     YAHOO.util.Dom.setStyle('progress", "visibility", "visible");
  26.     getpageviews("page_views", "<?php echo $start_date ?>", "<?php echo $finish_date ?>");
  27.    
  28. </script>

This example is from a report that scrapes Google Analytics and then presents the data. I wish I could say I was smart enough to figure out the Google Analytics stuff on my own, but I wasn't. It's a made-for-CakePHP solution and you can find it here at ThinkingPHP. Man, I love it when people smarter than me have figured stuff out. ;)

1 Comment

have your say

Add your comment below, or trackback from your own site. Subscribe to these comments.

Be nice. Keep it clean. Stay on topic. No spam.

You can use these tags:
<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

:

:


« TGIF
» Slides For My php|works Presentation “What Can PHP Learn From Ruby On Rails?”