Creating Filter Links in cakePHP

This is a short tutorial on how you can create reusable filter links, when you have lists of data that your users may only want to view a specific subset of.

So that this can easily be reused on multiple pages, the best method is to include it in a custom helper. I use a file called GeneralHelper.php for this type of functionality.

Filter Links (more…)

Ajax name check

When a user signs up to your website, trying to find a username that is not already in use can be a real pain and could cause them not to sign up if they are repeatedly presented with an error. To solve this you can use a simple bit of JavaScript to check if their chosen username is available before submitting their registration. (more…)

A word of warning to users of 1and1 and cakePHP

Something I found out recently when I updated the cakePHP core files, when accessing my 1and1 hosting using ssh I kept getting errors when using the cakePHP console. The problem was caused by the fact that by default 1and1 uses PHP 4 for the command line. This cannot be altered using .htaccess, however after a little googleing I found that using php5 on the command line does as you would expect. So to make your cakePHP console work using PHP 5, all that is needed is a little editing of one file. CORE/console/cake

Change this:

exec php -q ${LIB}cake.php -working "${APP}" "$@"

To this:

exec php5 -q ${LIB}cake.php -working "${APP}" "$@"

All console actions will then be run using PHP 5.

Dynamic Select Box

Recently I came across a problem, where I wanted to show a select box for zones in an address (counties or states etc.). I have a list of zones in my database and to put them all in one box would have been unusable as the list is in excess of 2000 zones. My solution to this was only show the zones related to the country selected in another select box. When the user changes the country the zones are updated. In this tutorial I will explain how I achieved this using cakePHP (1.3) and the YUI Library (3.1.1).

Bulk record update in Cakephp

I’m sure there are many ways of doing this, but recently I finally got round to figuring out how to update multiple records at a time.  When I started out all I wanted was to give all the selected records the same value for one database field, so the first thing we need to know is which records need to be updated and which field. To do this all you need is a list with your records (I’m using portfolios) inside a form with some check boxes and a select box with a list of actions. (more…)

Making flash messages disapear, with YUI.

Ok, so we all know how useful those flash messages are that cakePHP throw at us, “you’ve done it wrong, try again”. Well as much as I like them I don’t want to be reminded of my error untill I go to a different page. The answer is to make them disapear.

Using the YUI Animation Utility, we can simply make the div containing the message close to nothing. First you need to make sure your $session->flash() is wrapped in a div if it appears.


Paginating Data with CakePHP and Yahoo! User Interface DataTable

The aim of this tutorial is to be able to pull data from your database and output it in a nice shiny data table. Although the cakePHP paginator does this perfectly well, I have been using YUI and I am not a fan of the prototype library.

The YUI Paginator control is able to send requests to the server with parameters for the page required, the DataTable control can then format that data into our shiny table.

For this tutorial I have used CakePHP 1.2 RC3 and YUI 2.6.0. I am using a “Products” controller, model and corresponding views.

Thanks should go to this post by Mark Buckner (aka hydra12) describing how to use cakePHP with ExtJS DataGrid, for the inspiration and the some of the cakePHP code for this tutorial.


Baking websites with out a development team.

I have been dipping in and out of using a great open source Rapid Development PHP Framework called cakePHP for the past two years. Developing with this framework has meant I have been able to create functionality in websites a lot quicker and easier than I could ever have done without it.

This was by means my first venture into the world of open source software. As a solo web developer, I have always had to learn how to use the various technologies available, by myself and under my own steam. It was very clear to me from an early stage that if I wanted to learn how to do something, the easiest way would be to look at the approach of other developers.

This started with free scripts I found around the internet which only led to a mess of different scripts which was not maintainable. I then looked for a more complete offering and I came across open source content management systems (CMS) such as Mambo and Joomla, but I always found they were almost too complete. It takes some of the fun out of creating a website, when within just a few clicks hey presto you have a complete website, except for all the features that you really need.


To blog or not to blog…..

….that is the question.

I have been considering writing a blog for some time now, but haven’t really had the enthusiasm to go through with it. Now I feel is the right time as I now feel confident enough to sell my wares as a web developer. Hopefully this blog will provide some incite into my working practices and a bit about me for any prospective clients out there, somewhere, may be!

I’m sure someone will come accross my rambleings at some point, so if it is you hello and thank you for reading.

If you are interested in web design/development services please email me at