Converting a Multidimensional Array to an HTML List

Still a work in progress, and pretty rough: protected function _loopArray($data) { $string = ”; $count = 0; foreach ($data as $key => $val) { if ($count == 0) { if (is_numeric($key)) { $type = ‘ol’; $string = ‘ ‘; } else { $type = ‘ul’; $string = ‘ ‘; } } $string .= ‘ ‘; if ($type == ‘ul’) [...]

By Jamie with 0 comments
CakePHP 2: accessing the Request object from anywhere

If you’re working in a place other than a controller, view, helper, or component – such as an event listener, custom lib class, etc. – and need to access the CakeRequest object (which is available as $this->request in controllers/views/helpers), then use Router to get it: $request = Router::getRequest();

By Jamie with 0 comments
Using path conditions with Hash::extract() in CakePHP 2

The CakePHP book page on the new Hash class, the replacement for Set, is not exactly extensive. There’s even an error: the arguments for Hash::extract are $data, $path, but the example given uses $path, $data (the former is correct). One aspect of Hash that the book is particularly quiet on is how to use path conditions with methods such as [...]

By Jamie with 1 comment
Hockey Pool Geek / Blog Neglect

Wow, I’ve really been neglecting my blog lately – sorry, everyone! With two kids, a full-time job, and a couple of side projects it’s hard to find time to sit down and write blog posts. I’ve been pouring most of my extra energy and time into Hockey Pool Geek, which is a website built on CakePHP that I’m very proud [...]

By Jamie with 0 comments
Updated Copyable Behavior for CakePHP 1.3

THIS CONTENT IS OUT OF DATE! IF YOU’RE USING CAKE 2, YOU SHOULDN’T READ THIS. Wow, I haven’t posted anything on my blog for a while. I guess I must be busy. A new baby will have that effect. Anyway, I’m happy to release an update to my Copyable behavior, which I shared with everyone a few months ago. Download [...]

By Jamie with 7 comments
New theme… again

Trying out a new WordPress theme. My last one got boring fast. One of these days I’ll have enough time to make my own theme… maybe. It’s been a while since I’ve posted anything of substance, but stay tuned!

By Jamie with 0 comments
Copyable Behavior for CakePHP 1.3: Recursive Record Copying

THIS CONTENT IS OUT OF DATE! IF YOU’RE USING CAKE 2, YOU SHOULDN’T READ THIS. UPDATE June 02/10: Please check out the update to Copyable behavior Until I switched to CakePHP, any CMS I built for a client had a “copy this item” tool. The Cake framework doesn’t have anything like that built in, so for the past year or [...]

By Jamie with 10 comments
Cipher Behavior update soon – it’s coming

Yup, I realize that beforeSave() is a little wonky. My fault for not testing before making a major change. Update coming tonight on Github.

By Jamie with 0 comments
Cipher Behavior with Zend_Filter for CakePHP 1.3 – Easy Two-Way Encryption

THIS CONTENT IS OUT OF DATE! IF YOU’RE USING CAKE 2, YOU SHOULDN’T READ THIS. Here’s a quickie – a Cipher behavior for CakePHP to handle two-way encryption of sensitive data. If you want to store, say, credit card information, you’ll need a way to retrieve it later; Cake’s built-in security hashing is one-way, meaning that once it’s encrypted it [...]

By Jamie with 9 comments
Useful CakePHP Tutorial Roundup for January 29, 2010

Well, I’ve finally gathered enough good CakePHP links to warrant another tutorial roundup. It’s not that there haven’t been any good CakePHP posts out there – the blogs are full of ‘em, especially with 1.3 finally in beta – it’s just that I’ve been (and still am) pretty busy. But as always, I’m constantly coming across useful CakePHP tips, code, [...]

By Jamie with 0 comments