Web Dev Blog

Exploring web development and related foobar.

Importing Data from CSV into CakePHP

This is a quick little method that lets you get some data from a CSV into a table. It should work with very large CSV files as it only has to read one row at a time.

Detect Page Start and Navigation Away in jQuery

This quick snippet of jQuery that will allow you to so do something before the user navigates away from a page or closes the browser or tab. In this example I have mixed in some JavaScript Date functionality to give a timer of how long you were on the page.

Auto-Set the ID beforeSave in CakePHP

In this quick snippet of code I will be setting the ID of a model based on other fields given. We want to save a note about each Post that is different for every Client, however we do not want to have to get the ID every time we save the data.

Working with HABTM Form Data in CakePHP

I would like to document several speedy ways I have of working with HABTM data.

View a Random Record in CakePHP

This is a simple action to display a random record. Possibly useful for sites wanting to keep people clicking on something.

Update Multiple Records using Multi-Actions in CakePHP

In this CakePHP tutorial I will explain how to update multiple records in a single action. This will typically be used as an extension to the index views in your application, allowing a user to select which rows they would like to update, and then performing an action.

Simple Auth with Users HABTM Groups in CakePHP

In almost every project I need to setup some sort of login, and usually it requires group access to certain data depending on different criteria. For example I may have groups Admin+Member and I want Members to only be able to see other Users Profiles if the other Profile is active.

Search Forms in CakePHP

In this CakePHP tutorial I would like to show you how I handle search forms, while preserving pagination. The basic principal is to read the posted variables, and redirect the user to a page with the appropriate filters in the URL.

Page Breadcrumb Links in CakePHP

I wanted to make a quick and easy breadcrumb that worked with a simple array. The breadcrumb is an array containing multiple links from html_helper::link().

Multiple Flash Messages with Style in CakePHP

In this CakePHP tutorial I will explain how to output multiple flash messages. This forms a message stack that can be used to inform the user that multiple events have taken place.

Merge your Add and Edit actions into a Single Form in CakePHP

This CakePHP example will show you how to merge your Add and Edit forms into a Single Form action. This may be of benefit if you have a form with complex controller logic that you don't want to duplicate.

Fun with Tree Behaviour in CakePHP

I had a play with the Tree Behaviour in CakePHP and was very impressed at what you could create with such ease.

Attach Comments to Any Model in CakePHP

This method of linking models allows you to have a single table of data, say Comment, that is related to any one of a number of other Models (eg: Post, Event).

Admin Editable Settings and Theme in CakePHP

Usually the client will request for me to give them a way to edit simple settings in their application. I decided to read all the variables from the database in the beforeFilter to make them available in any controller.

Load CSV or Delimited Data from a File into a Named Array

This small snippet will allow you to load CSV or other delimited Data from a File into a named array. The heads in the CSV file will be used for the names of the array keys.

Regular Expression for Date or Datetime Validation

This Regular Expression will verify if a date is a valid YYYY-MM-DD with an optional HH:MM:SS. It checks to see if the day is a valid day in the given month with the consideration of leap years.

Merge Your CSS and JavaScript Using PHP

Merge all of your CSS and JS into one file to improve server speed.

Useful Exim Commands

A list of a few commands useful for managing an exim mail server.

Word Permutator Function

Give this function a phrase and it will return all of the permutations of the words that make up the phrase.

SWFUpload with cPanel and mod_security

I searched long and hard to find what was causing swfupload to fail on my cPanel, but work on my test environment so I thought I better save the result incase I need it again.