A behavior for CakePHP 2.x Background I stumbled upon this fork and SimpleScope. The latter has the disadvantage of redundancy in the scope conditions when used in multiple find configs. The first was pretty much how Rails’ scopes work. But…
Tag: Behavior
ResetBehavior and HazardableBehavior
ResetBehavior Reset is a new behavior I recently had to write to update some geocoded entries as well as records with processed titles/slugs – via beforeSave() – that had to be re-saved with a corrected processing method. Basically, it is…
Localized number formats for forms
Often your language is not english and therefore the locale settings for decimals are not . for decimals and , for thousands, but the opposite, for example. If you do not allow localized input/output in your CakePHP apps it often…
Typographic Behavior and Typography Helper
For CakePHP Apps. What is the issue here? Typography has quite a few regional differences. In some countries/languages you use quotation marks like so: “Hello” // English, curly, often in texts (1) «Hello» // French, brackets, often in texts (2)…
Geocoding with CakePHP
Geocoding is a very powerful tool if you want to work with lat/lng, distances or just want to display a small map for your addresses. I use it in combination with my GoogleMaps Helper to display a dynamic or a…
Helper? Component? Lib? CakePHP2
Note: For 1.3 see the old article on this subject. I want to outline some ideas on how to chose the appropriate class type if you want to add some additional feature to your cake app. For a beginner it…
Bitmasked – Using bitmasks in CakePHP
Introduction Based on Mark Story’s Post about this and the need in one of my apps for this lead me to believe that a behavior would be most appropriate to handle this. So I gave it a try. There already…
Working with passwords in CakePHP
The basics Usually, this is already well known. But.. there are still developers who actually store the password unhashed. You always have to store user passwords hashed. You can either use the still very common sha1 method (which is the…
Working with models
Since there is so much to talk about it here, I will cut right to the chase. We all know about "Fat Models, Slim Controllers". So basically, as much as possible of the code should be in the model. For…
Behaviors in CakePHP
I didn’t use behaviors for the first 12 months with Cake. I regret it now, because the code is no much cleaner and easier to extend. Let’s make a test with a simple task. We need some additional statistics to…