image_nation

Image_nation – a new CodeIgniter image library for automatic cropping and/or resizing of images

Please allow me to introduce to you another one of my libraries. This one is good for manipulating images. Every site that has images for products/posts/pages use at least two different sizes (if not more…): one for a thumbnail and one for featured images (and maybe one for a slideshow, etc.).

This library will allow you to automatically create the different dimensions of the images right after you upload it. All you have to do is set the width and height of the images you want created and give the library the path to the image that you want processed. Continue reading

freerider

Laravel 4 Model Events: Dynamicaly populate columns on insert/update

When I create some sort of admin panel, I usually want to know not only when a user created or edited an item (post), but also who that user was.

Considering this, I always add two additional columns to my tables: created_by and updated_by. This, along with the timestamps from Laravel, is the best way to keep track of latest changes of a database record. Continue reading

multi-level menu

Multi-level menu in PHP – how to do it without killing yourself or the database in the process

Well. It’s been a long time since I’ve written a post. I was busy learning Laravel… Currently, I am trying the framework by working on a CMS, and, again, I have arrived at the phase of menus. And by “menus”, I am refering to multi-level menus. In the past I have found ways to bypass this dilemma, but now my time allowed me to dive into it. Continue reading

Codeigniter – Convert an array to object

I usually use the results that come from the models as objects (not as arrays). However, there are moments when I need to work with the results before sending them to the view. In this case, getting the results from the model as an array is preferable. But, when I send them to the view, I would like to work with objects. So now I need to convert the array into an object. Continue reading

How to use a “Cookbook” with Codeigniter

cookbookI was asked to do a review for Codeigniter 2 Cookbook, written by Rob Foster and published by Packt Publishing (to be honest, I actually asked to review the book to get it for free).

I haven’t managed to keep the promise of reviewing the book in due time, but suddenly I realised that every now and then I return to the book to uncover a new programming style that makes me say: “Ahaaa”. Continue reading

rules

Forms? Keep the validation rules inside the model

As always, when talking about forms we also talk about validation. For a long time I’ve validated the forms inside the controllers because it is fast and simple – no more browsing between files.

But after a while you find yourself having a controller which is becoming more complex and bigger. So why not keep at least the validation rules somewhere else? Continue reading