zen of coding

Nice trick to toggle your Model field in CakePHP

This little trick will allow you toggle any field, for example ‘status’ which can be either 0 or 1… Add this little function to your model or better yet, app model: Update 1: Thanks to Kalt for the sound improvement to the original method Update 2:¬†And thanks to rafaelbandeira3 for[…]

Read More »

Use Sanitize::html() class in the views

Update (9/16/2008): As some people pointed out it’s easier to use the h() method defined in basics.php of the core, it achieves the same basic goal, but since Sanitize class has other methods and purposes, I’m gong to leave this as an informational example and food for thought. (i.e. you[…]

Read More »

Use Set::merge() to modify the $paginate property

Let’s say you have a Posts controller, where you’ll need to paginate some posts in various actions. You might have some “generic settings” as the manual recommends in your $paginate variable similar to this: var $paginate = array(’Post’=>array(’limit’=>10, ‘order’=>array(’Post.modified DESC’))); Now, the above setting is probably going to work well[…]

Read More »

Book review: CakePHP Application Development

Nice folks over at Packt Publishing asked me to a do a review of a book they’ve recently published, called “CakePHP Application Development“, by Ahsanul Bari and Anupom Syam. I was quite happy to oblige and not only because I got a free book, but also because I’ve been meaning[…]

Read More »
%d bloggers like this: