Hi guys, how can I make a shortcut function for this Yii::app()->params[$name]?
thanks
Hi guys, how can I make a shortcut function for this Yii::app()->params[$name]?
thanks
function p($name=null){
$params=Yii::app()->params;
if($name===null)
return $params;
return $params[$name];
}
Hi thanks for the reply
i tried to use this one but it does not display the array. i have this array
'test'=>array(
'http-equiv'=>'Content-Type',
'charset'=>'text/html; charset=utf-8',
'language'=>'Content-Language',
'robots'=>'index, follow')
check the output
print_r(p());die;
also, the values you mentioned must be in the config in the index "params"
this is my actual code
Yii::app()->params['metaName']['language']
is your config like this ?
return array(
'...'
'components'=>array(
'...'
),
'params'=>array(
'metaName'=>array(
'language'=>'..'
),
),
);
if yes, p(‘metaName’) should return an array containing the language
nope. this is my config
'metaName'=>array(
'http-equiv'=>'Content-Type',
'charset'=>'text/html; charset=utf-8',
'language'=>'Content-Language',
'robots'=>'index, follow')
the "params" component must be in configured like I said above, at the "params" index of the config
when you change to be like that, it will work as you expect
ah ok thanks.
about my config? how can i make a shortcut for that to work?
you can’t
the configuration options you set there are the configuration for the Yii Application, either web or console
Here is a list of the options you can set for a web application
As for your own parameters, define like you were doing, as params of the application
I see… thanks for the help bro…
Glad I could
Cheers