Site wide settings with Configure::write and read
Hello.
I'm currently trying to achieve editable site-wide setting for my website with Configure::write and read.
My db had id, name and value (ex: 1, site.name, My site)
I have this function in AppController :
function fetchSettings(){
//Loading model on the fly
$this->loadModel('Setting');
//Fetching All params
$this->set('settings', $this->Setting->find('all'));
$name = $setting['Setting']['name'];
$value = $setting['Setting']['value'];
foreach($settings as $setting){
Configure::write("$name", "$value");
}
}
This is my setting Model :
<?php
class Setting extends AppModel {
public $validate = array(
'name' => array(
'rule' => 'notEmpty'
),
'value' => array(
'rule' => 'notEmpty'
)
);
}
And in my view I use :
Configure::read('site.name')
But it does'nt work... any idea ?
-- Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org
Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions.
To unsubscribe from this group, send email to
cake-php+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php
0 Comments:
Post a Comment
Subscribe to Post Comments [Atom]
<< Home