Hi,
Everyone, thanks a lot for all this information!
Given the fact that the id could change, I have changed tom's tutorial
(thx!) a bit, making it able to function without the core.php editing and
being more flexible. (When you add a new field in the database, it
automatically get's added to the settings).
Before I show you what I have changed, I do have one more question. It seems
to mee that the cache doesn't work. (Because a debug inside the block that
checks if it's cached, get's always activated.)
Do you need to do configuring before caching works?
Anyway, I'll google this myself too.
This is what I have made from it:
<?php
class AppController extends Controller {
function beforeFilter() {
$this->pfSettings = $this->getSettings();
$this->set('site_name', $this->pfSettings['name']);
debug($this->pfSettings);
}
function getSettings()
{
//check to see if they are in the cache.
if (!$cachedSettings = Cache::read('settings', 'long')) {
//fetch the settings from the database.
if($settings = $this->Setting->find('all')) {
$configurations = array();
foreach ($settings as $setting):
//$configurations =
array_merge(array($setting['Setting']['key']=>$setting['Setting']['value']));
$configurations[$setting['Setting']['key']] =
$setting['Setting']['value'];
endforeach;
Cache::write('settings', $configurations);
return $configurations;
}
else
{
exit();
}
} else {
//return the cached settings.
return $cachedSettings;
}
}
}
The debug outputs:
Array
(
[name] => WebsiteTite test.
[description] => This is a litlle text about this photoboot photoblog
website.
)
--
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
[email protected] For more options, visit this group at
http://groups.google.com/group/cake-php