Posted by Doug Hays on the 11th of January, 2010 at 11:13 pm under CakePHP.    This post has no comments.

In order to call CakePHP from non-CakePHP code, we will copy index.php from /app/webroot and put it into our non-CakePHP codebase as cakephp.php.

Then, we’ll create a function requestCakePHP that requires the cakephp.php file:

function requestCakePHP($url)

{

// Set the url parameter for cakephp
$_GET['url'] = $url;

require_once 'cakephp.php';

// Fire up CakePHP and buffer results
ob_start();
$Dispatcher= new Dispatcher ();
$Dispatcher->dispatch($url);

return ob_get_clean();

}
?>

Then, whenever we need to call for some Cake, we just call requestCake with the URL minus the hostname:


echo requestCakePHP("/webpages/view/2");

In the example above, I have a webpages controller, a view action and am viewing webpage #2.

Posted by Doug Hays on the 9th of September, 2009 at 9:13 am under CSS and Google Maps.    This post has 2 comments.

It always feels good to solve a long-standing and puzzling issue.  Today’s fix has to do with a Google Maps window that was about 50% taller than it had to be:

Google Maps Info Window - Too Tall

After several rounds of setting fixed widths inside the info window’s HTML content, I added the following CSS for .gmapmarker which is the class of the div that wraps all of my info window’s content:

#gmapmarker {
display: block;
max-height: 185px;
}
.gmapmarker {
    max-height: 185px;
}
And that did the trick:
Google Maps Info Window - Height Fixed
Posted by Doug Hays on the 17th of May, 2009 at 11:31 pm under AIR and Flex.    This post has 3,192 comments.

There is an issue with AIR application development to which I still have not found an official answer.

I just need to switch between http://localhost and http://fakeproductionurl.com depending on whether I was running in Flex Builder (via adl).

I found all sorts of articles about using conditional compilation (yikes) and reading XML files (I’m too lazy).

This is what I ended up using:

if (NativeApplication.nativeApplication.publisherID != "") {
   return "http://fakeproductionurl.com";
}
else {
   return "http://localhost";
}

It doesn’t give you the ability to switch between 3+ different environments, but it’s a very easy way to toggle between development / production environments.

Posted by Doug Hays on the 17th of March, 2009 at 4:02 pm under CakePHP.    This post has 145 comments.

I needed to test some CakePHP code on a client’s 1and1 server today, so I dropped my CakePHP app in a subdirectory (called agents2) on his site.  But, after doing so, I kept getting “Class ‘Configure’ not found”.  Luckily, I stumbled upon this blog post over at kushaura.com which saved me.

The core issue was with my root .htaccess file which needed to be changed to:

      RewriteEngine on
      RewriteBase    /agents2/

      RewriteRule    ^$ app/webroot/    [L]

      RewriteCond %{REQUEST_FILENAME} !-f
      RewriteRule (.*) app/webroot/$1 [L]

And that did the trick.

Thanks, Kushaura.com!

Posted by Doug Hays on the 26th of November, 2008 at 11:02 pm under Coding.    This post has 319 comments.

In doing some research on ASP.NET MVC, Phil Haack mentioned a pattern that I had never heard of but love to use: PRG -or- Post, Redirect, Get.

Take a web form for example.  When the user clicks Save, the data is sent via POST back to the web application.  The web app saves the data to the database and then redirects the user to the next page within the application.  The user’s browser then requests that page via GET.  

The beauty of this pattern is made very clear by Phil.  This will eliminate the possibly confusing “Are you sure you want to resubmit this form data?” browser message.  But, for me, an even better reason is that it eliminates possible data issues when the browser re-posts the data after that refresh.  

Either way, I’m glad to have learned the name of this pattern and even more thankful that my use of it has been validated.