Feed items

Integrate CakePHP and jQuery UI

jQuery UI provides many fancy user interfaces for web developers. You can follow the steps below in order to use jQuery UI in CakePHP.
1. Download the jQuery UI library at jqueryui.com
 
2. Unzip the downloaded archive and copy the css folder and two .js files to /app/webroot

  • css/
  • js/jquery-1.4.2.min.js
  • js/jquery-ui-1.8.4.custom.min.js

 

CakePHP – Apply Time Zone for Users

You can make use the TimeHelper to offset the time by user specified time zone. What u need is adding a new time_zone column in the users table just like the following example.

--MySQL
CREATE TABLE IF NOT EXISTS users (
user_id INT NOT NULL auto_increment,
name VARCHAR(45) NOT NULL,
password VARCHAR(45) NOT NULL,
time_zone DECIMAL(5,1) NOT NULL,
created DATETIME DEFAULT NULL,
PRIMARY KEY (user_id)
) ENGINE = InnoDB;

 

Ajax implementation on CakePHP @ 3

Recently i have started another CakePHP project. i found that the example in Ajax implementation on CakePHP @ 2 should be changed as follow.
ajax_controller.php

<?php
Class AjaxController extends AppController {
var $name = 'Ajax';
var $helpers = array('Form','Html','Javascript', 'Ajax');
var $components = array('RequestHandler');

function afterAjaxAction () {
// get the $this->data to collect the form information
// save the object to database
// render the after_ajax_call.ctp
$this->render('/elements/layout/after_ajax_call');
}
}

 

Opening .ctp file with Syntax Highlight in Eclipse

The view file in CakePHP is with .ctp extension. By default, Eclipse does not know which editor should be used to open this kind of file. If you associate it with PHP Editor in Preference -> General -> File Association, you will find there is no syntax highlight in the editor.
Here comes to the solution.

1. Go to Preference -> General -> Content Type
2. Select PHP Content Type under Text in the top right list

CakePHP – Open an xml Formatted .xls in OpenOffice

About a half year ago, i posted an article about exporting data to an .xls file in CakePHP.
CakePHP – Export data to a .xls file

CakePHP – Export data to a .xls file

We have talked about how to read data from an excel file in previous articles.
CakePHP – php-excel-reader
CakePHP – Read data from an excel file into an array

Now i would like to create a .xls in CakePHP. i found the following article in CakePHP Bakery talking about the xls helper. i tried to follow the article but i dun know y it doesn’t work.
Excel xls helper

CakePHP – Read data from an excel file into an array

In the last article – CakePHP – php-excel-reader, we have implement the php-excel-reader. Now i would like to read the excel content for processing instead of just displaying it in the view.

This article assume that you have already implemented the php-excel-reader. Please refer to CakePHP – php-excel-reader.
I have searched on google and find a good post about reading the excel content into an array using the php-excel-reader.
Reference: Alexander Makhno’s Blog » php-excel-reader

CakePHP – php-excel-reader

The next enhancement on the BHJS Alumni website is adding an import function such that a bench of graduates could be created in the Database without adding new member one by one. Importing the records from an excel file would probably the most common and straight forward way.

The following procedures would guide you to implement the php-excel-reader in your CakePHP project.

CakePHP – Email Validation

After working for about one year, the BHJS Alumni website phase 2 is completed. But after it is deployed in production server, i found that some email addresses are regarded as invalid email address. The email validation rule which i used is provided by CakePHP. Only email addresses ended with .com, .org etc… could pass the validation rule.
So i ask the Google teacher and luckily i am not the only one to come across this problem.

Email Validation in cakephp
What i can do is writing my own validation rule which can be doned by regular expression in the model.php. Again, Google is really helpful and there are many regular expressions for email validation. Finally, i pick the following one.

FlashChartHelper @ 3

Some times if you wanna show more than one chart in the view. You can make use of the render function such that different charts are shown in different div by providing the div id.