search
top
Currently Browsing: CakePHP Snippets

Model::save blacklist – in reply to teknoid

It’s not that i did not know what else to post, but here’s a more general approach for those who like using blackList over whiteList when tighten up save() calls. This post is ment as follow up to the one teknoid posted. Instead of doing the array_diff stuff in your controller, you could do it in the model (respectively, all models). So here it goes. I made the $blackList part optional, but... read more

Fancy URLs with Inflector::slug

Motivated by my recent tweet i thought i share my method of replacing the old SluggableBehavior with core functions. Sometimes we have more than one model that uses slugs. For example: Tags, Posts, Categories. That’s why i add the following to AppModel which allows me to call it on any model. function slugify($text) { return low(Inflector::slug($text, '-')); } But because i am lazy i just use one of... read more
 Page 2 of 4 « 1  2  3  4 »
top