I’ve rewritten my image helper to extend off of CakePHP’s built in HTML helper, rather than reinvent the wheel. The major benefit of using this helper is that it determines the image dimensions, if not specified, and applies them to the image tag, which is one of Google’s rules to optimize browser rendering. <?php/** * This… Continue reading CakePHP Image Helper
Category: CakePHP
CakePHP HasAndBelongsToMany (HABTM) Checkboxes Instead of Multiple Select
Changing CakePHP’s default multiple select for HasAndBelongsToMany (HABTM) relationships to use multiple checkboxes used to be an arduous task. It is now a simple option as follows. If you have a Post model that has a HABTM relationship with a Tag model, you would use the following line to display multiple checkboxes instead of the… Continue reading CakePHP HasAndBelongsToMany (HABTM) Checkboxes Instead of Multiple Select
Akismet API Component for CakePHP 1.2
This is a component for CakePHP 1.2 and PHP 5+ that utilizes the Akismet API to fight comment SPAM. You will need an API key, which can be retrieved from wordpress.com. <?php/** * This is a component for CakePHP that utilizes the Akismet API * * See http://akismet.com/development/api/ for more information. * * Licensed under The MIT License *… Continue reading Akismet API Component for CakePHP 1.2
CakePHP Reverse Routing
CakePHP provides a very strong and flexible routing engine, for both routing, and reverse routing. Creating a route for the home page is as simple as adding the following line to your routes.php configuration file. Router::connect(‘/about_us’, array(‘controller’ => ‘pages’, ‘action’ => ‘display’, ‘about_us’)); Now, anyone visiting http://example.com/about_us page, will see the view defined in your… Continue reading CakePHP Reverse Routing
Disabling Layouts and Views in CakePHP
It is easy to disable both the layout and view in CakePHP by putting the following line in your controller action: $this->autoRender = false; If you want to disable just the layout, use the following line in your controller action: $this->layout = false; And if you only want to disable the view for this action,… Continue reading Disabling Layouts and Views in CakePHP
CakePHP Image Helper for Front End Optimization
Going along with one of the many ways to optimize front end performance, I created an image helper for CakePHP that will get the image dimensions and include them as html attributes. <?php /** * This class builds an image tag. The main purpose of this is to get the image dimensions and * include the appropriate… Continue reading CakePHP Image Helper for Front End Optimization
Image Resizing Class
This is a simple script to resize images with PHP. It uses the GD Library functions, and is currently not compatible with ImageMagick. It will automatically determine the image type and use the appropriate functions to resize. <?php/** * This class handles image resizing. It will automatically determine the image * type and use the appropriate php… Continue reading Image Resizing Class
CakePHP Upgrade from 1.1 to 1.2
CakePHP 1.2 has finally released, but how do you upgrade site your site running CakePHP 1.1? It is a fairly simple process with brief formal instructions on cakephp.org. Most will only have to make a few changes as CakePHP 1.2 is not backwards compatible. All of the html helper form element methods have been moved… Continue reading CakePHP Upgrade from 1.1 to 1.2