Define general array and variable and call it to anywhere in application

You are viewing revision #1 of this wiki article.
This version may not be up to date with the latest version.
You may want to view the differences to the latest version.

next (#2) »

Create param.php file in protected/config

Yii::app()->params['TEXT_ACTIVE'] = 'Active'; //1 for active

Yii::app()->params['AD_LAYOUT_POISITION'] = array(
													"1" => array(
																	'width' => '1000', 
																	'height' => '150'
																),
													"2" => array(
																	'width' => '200',
																	'height' => '150'
																),
													"3" => array(
																	'width' => '1000',
																	'height' => '150'
																),
													"4" => array(
																	'width' => '200',
																	'height' => '150'
																),
																												
													);

Now include this file in protected/config/main.php

require_once( dirname(__FILE__) . '/params.php');
return array(
	'basePath'=>dirname(__FILE__).DIRECTORY_SEPARATOR.'..',
         ....

Now suppose I have to call TEXT_ACTIVE I will write in my file as

echo Yii::app()->params['TEXT_ACTIVE'];

1 4
3 followers
Viewed: 14 443 times
Version: Unknown (update)
Category: Tutorials
Tags:
Written by: bhavesh vaghela
Last updated by: Maurizio Domba Cerin
Created on: Jan 16, 2013
Last updated: 11 years ago
Update Article

Revisions

View all history