Monday, March 5, 2012

Multi column layouts and floating , #jquery

Have you ever tried to have a dynamic multi column layout, and float the divs nicely under neither each other?
This morning I was tempting to dynamically build a 2 column  menu for a restaurant,  however  I couldn't get my left column divs to sit under the one above.


Jquery to the rescues,  Masonry is a simple, very easy to use plugin that will do this for you.

http://masonry.desandro.com/


Tuesday, February 21, 2012

CakePhp file upload plugin

After much, MUCH googling i found this awesome file upload plugin. It has a great thumbnail feature and some really good validation options.

https://github.com/josegonzalez/upload/tree/2.0

However I found out you cant randomize the file name. (There is an option to randomize the folder it store the file in). After a bit of hack and slash i managed to append a random string 'time()' to file name.

/app/Plugin/Upload/Model/Behavior/UploadBehavior.php

//Line 78
private $rand_str;

//Line 87(inside the setup function)
$this->rand_str =  time();
//End of the beforeSave function
$model->data[$model->alias][$field] = $this->rand_str."_".
$model->data[$model->alias][$field];

This will append the UNIX time stamp to the file you're uploading as well the file name stored in the table and all the thumbnails.

Monday, February 20, 2012

Cakephp & Smartyhost

I recently found out smartyhost.com.au doesn't play well with cake Sessions.

'Please verify that the current setting of session.save_path is correct'

A simple fix for this is to change the Sessions from php to cake


/app/config/core.php
 Configure::write('Session', array(
  'defaults' => 'cake'
 ));

This will force Cake to use the /app/tmp path for Sessions instead of the Session path defined in smartyhost servers.