Showing posts with label yii. Show all posts
Showing posts with label yii. Show all posts

Jun 25, 2011

apache and htaccess

1. in your Directory

DirectoryIndex index.php index.html
Options Indexes FollowSymLinks MultiViews
AllowOverride All ##### this should be All
Order allow,deny
allow from all


2. in your /var/www/xxx folder, add file .htaccess
Options +FollowSymLinks
IndexIgnore */*

RewriteEngine on
# if a directory or a file exists, use it directly
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
# otherwise forward it to index.php
RewriteRule . index.php

Apr 1, 2011

About error messages and locales

Localization
1. create file for localization
/protected/messages/
/en/default.php
/cn/default.php
/jp/default.php

2. specific a lang
Yii::app()->language = "en"
: this means your en folder under /protected/messages.

3. in your default.php, write things as follows,

return array(
'name' => 'xing ming',
'required' => 'bu neng wei kong',
);
?>

4. anywhere you want to use the localized name, write,
Yii::t('default', 'name');

custum error message.
1. in your model/Model.php, find function rules.
return array(
array('name, mail', 'required', 'message' => Yii::t('default', 'required'); ),
);

2. This tag will show all the form errors in a block.
The second param is the title of the block.
Here I leave it blank.
errorSummary($model, ""); ?>



Jan 24, 2011

Yii - default timezone

1.set default timezone
Encountered an error which was described here:
http://php.net/manual/en/function.date-default-timezone-set.php
I added the following line to the index.php
date_default_timezone_set("Asia/Tokyo");

2.Gii

'modules'=>array(
'gii'=>array(
'class'=>'system.gii.GiiModule',
'password'=>'123456',
'ipFilters'=> array('localhost', '127.0.0.1', '192.168.2.249'),
),
),



3. Gii
"CDbConnection failed to open the DB connection: could not find driver"
I didn't get the proper pdo_php support.
I re-configured php using the following command:
./configure --with-apxs2=/usr/local/apache2/bin/apxs --with-mysql --with-pdo-mysql

...fixed now

Sep 22, 2010

NOTES about YII

1. gii

'gii' =>array(
'class' => 'system.gii.GiiModule',
'password' => '****',
'ipFilters' => array(
'127.0.*',
),
),