zen of coding

Give all of your error messages a different layout

By default CakePHP will use the default.ctp layout to display any error messages. In some cases this may not be desirable as your default.ctp might contain navigational and design elements, CSS and JS files, which really take away from the way the error message is displayed. Usually an error message[…]

Read More »

Simplistic example of row-level access control with Auth, Security and App Model in CakePHP

Let me just preface this post, by saying that this is indeed a very much simplified example. The main purpose here is not to provide a solution that will fit any application, but rather give a decent foundation to further expand your own solution. The example is based on Auth[…]

Read More »

More pondering about HABTM (let's save new tags with a post)

There is a number of examples (some you can find even on this blog) on how to save a Post with a few Tags. Most of them, so far, had shown how to easily save Tags when the ID’s are already known. Now, we’ll take a look at how to[…]

Read More »

A little tip about counterScope

One of many cool CakePHP’s features is the Counter Cache. From the manual: “This function helps you cache the count of related data. Instead of counting the records manually via find(‘count’), the model itself tracks any addition/deleting towards the associated $hasMany model and increases/decreases a dedicated integer field within the[…]

Read More »

Blend PHP and JavaScript in CakePHP

I guess it’s no big secret that you can easily serve JavaScript files with some PHP content, by using something like: <script type="text/javascript" src="myscript.php"></script> Let’s take a quick look at how this applies to CakePHP and what (hopefully) useful tricks you can accomplish by employing the following techniques… First, we’d[…]

Read More »
%d bloggers like this: