Archive

Archive for July, 2010

Colorbox: resize iframe dynamically

July 30th, 2010

As Colorbox can not auto calculate iframe’s width and height, therefore developer has to give a specific width and height when using Colorbox with iframe.

And here is my solution to resize iframe dynamically, meaning using this workaround, you can leave it for Colorbox to calculate iframe’s width and height and resize it.


$(".colorbox").colorbox(

{iframe:true,

innerWidth:0,

innerHeight:0,

scrolling:false,

onComplete:function(){

$.colorbox.resize(

{

innerHeight:($('iframe').offset().top + $('iframe').height()),

innerWidth:($('iframe').offset().left + $('iframe').width())

}

);

}

}

);

What we did here is firstly we create Colorbox with 0 width and 0 height, when it is loaded, we calculate the document size of the iframe content and resize it using Colorbox’s API

admin 2-Javascript, General Javascript, JQuery

CakePHP common errors part 3

July 9th, 2010

This is a very strange error I have met in my last project, which is JSON data being cut off on my server when it is working fine on my localhost.

The case is I have an array($arrayData) with 300 length, and I am using $javascript->object($arrayData) to encode it to JSON in the view(json-view.ctp). It gives correct JSON data on my localhost, however when I moved the application to live server, it keeps on giving an incomplete JSON, which causes an incorrect JSON format. I tried to google for the solutions, some guys suggested to look into the php config file, to set max_execution_time and so on, but it did not solve the problem.

I have not found the cause of the error so far, however I have found out a workaround, and I hope you find it helpful too:
instead of using CakePHP built-in JSON encode function($javascript->object), I used native php JSON encode function(json_encode), and I need to encode it direct inside my controller action, and that solves the problem. Taking my application as an example, for json_view.ctp, leave it blank, and inside controller action jsonView(), do $jsonData=json_encode($arrayData); echo $jsonData;

If you know the reason which is causing this, do let us know!

admin 1-CakePHP, General Cakephp

Map My Client

July 6th, 2010

mmc

MMC(map my client) combines the power of Google Map and CakePHP to give you an easy way to manage your clients(contacts) from a geography view.
With the power of Google Map, you enable yourself and coworkers to view your clients on a map. With the power of CakePHP,
you can update clients’ info from user-friendly admin panel and create different roles to view/manage the map.

Feature:

  1. Automally geocode from a valid address, no need to use any third party tools to find out the lat/lng of an address. MMC will do this for you.
  2. Authentication is required to view the map.
  3. Admin has the power to create two different roles of users which are admin user and member user. Admin user has the power to manage content, and member user only has the right to view the map.
  4. CakePHP made the installation even easier. Just upload the whole folder into your server and do some minor configuration.

DEMO:

Demo Page: http://www.the-di-lab.com/mmc

Admin: admin/admin

Client: client/client

Get it now from CodeCanyon: http://codecanyon.net/item/map-my-client/111279

admin 3-Code Canyon Items

Get Adobe Flash playerPlugin by wpburn.com wordpress themes