Yet Another Multicolumn Layout (YAML)

Development, External Sites, Frameworks, Labs, Tools June 27th, 2008

Today I found a nice CSS framework which claim to solve the multi-column layout issues which everyone of us meet during the construction of the web site design.

Actually I am speaking about YAML - Yet Another Multicolumn Layout. At first time I mix it with Yaml.org, but actually it’s a different thing. It’s a set of CSS files + few image files which would sort the issues with multi-column layouts.

The benefit is the availability of good documentation and nice examples.

Hope you found it helpful.

Using more than one database connection in CakePHP

CakePHP, Development, Frameworks, Labs, PHP April 10th, 2008

Probably is pretty obvious for most of the advanced users, but when I started my experience with CakePHP I read a lot of configuring a database, but not multiple ones. There are articles how to use database for development and for production without changing anything but rewriting a function in DATABASE_CONFIG class.

These days we need to choose way of splitting the functionality and we have to decide: Shall we use different databases or shall we put a prefix for every table. So far we choose to use prefix, but I dig into this and I realized that every model could be attached to different database.

Here is the example how to do this:
Read the rest of this entry »

Using different Date format in CakePHP 1.2

CakePHP, Development, General, Labs, PHP December 20th, 2007

Here I would like to show you a behaviour which will help you to handle different date format than yyyy-mm-dd supported from the database. The reason why I created this behaviour is because in most of my projects I had a requirement to display the date format in human readable format.

So, without extra words here is the behaviour class:

Read the rest of this entry »

Check for existing children behaviour

CakePHP, Development, Frameworks, Labs, PHP October 23rd, 2007

In some of my projects I had a requirement to prevent deletion of the records, which had children. That’s why I create a small behaviour which checks these cases and prevent this.

Add this code in /app/models/behaviours/has_children.php

<?php
/**
 * Prevent deletion if child record found
 *
 * @author    Nik Chankov
 * @url    http://nik.chankov.net
 */

class HasChildrenBehavior extends ModelBehavior {
    /**
     * Empty Setup Function
    */

    function setup(&$model) {
        $this->model = $model;
    }
   
    /**
     * Run the check and cancel the deletion if child is found
     * @access public
     */

    function beforeDelete(){
        if(isset($this->model->hasMany)){
            foreach($this->model->hasMany as $key=>$value){
                $childRecords = $this->model->{$key}->findAll(array($value['foreignKey']=>$this->model->id));
                if(count($childRecords) > 0){
                    return false;
                }
            }
        }
        return false;
    }
}
?>

Read the rest of this entry »

Advanced Datepicker helper for CakePHP

CakePHP, Development, Frameworks, Labs, PHP September 13th, 2007


I am using this part of code from long time ago, but it wasn’t in a separate helper. It was part from one not very good written Auth component/helper mash up which I already not using. I fact the default Date input of CakePHP Framework is ugly and not user friendly at all. The drop-downs are good because the format is clear and users cannot mess it, but if you thinking for the user convenience, then you should know that it’s 3 times easier just to type the date in a field or to pick it from a Calendar pop up than selecting from 3 drop-downs.
Read the rest of this entry »

Instant and Lightbox Together

Ajax, Development, JavaScript, Labs June 18th, 2007

These days I saw an article about Instant Javascript Library. I was surprised how easy is to build eye-candy gallery looking like real album photos. The usage of gallery is very easy - just include the script file and add class of every image and that’s it. Of course there are many customizations and extras, but I am leaving this to your imagination.
Read the rest of this entry »