forked from sams/Configuration
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathREADME.txt
69 lines (44 loc) · 2.34 KB
/
README.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
Configuration Plugin
======================
Version: 1.1
Author: Nick Baker
Email: [email protected]
Website: http://www.webtechnick.com
Updates: http://www.webtechnick.com/blogs/view/223/CakePHP_Configuration_Plugin
Get it
======================
Download: http://projects.webtechnick.com/configuration.tar.gz
SVN: http://svn.github.com/webtechnick/CakePHP-Configuration-Plugin
GIT: [email protected]:webtechnick/CakePHP-Configuration-Plugin.git
The Configuration plugin is an extremely useful way to store site-wide configuration. The configuration plugin stores
your configuration into your database and is made available throughout your site (views, controllers, models, tasks, etc...)
========================= Install =========================
1) Copy the /configuration folder into /app/plugins/
2) run "cake schema run -path /plugins/configuration/config/sql -name config" in a terminal to build your database.
========================= Setup =========================
1) Open up your app_controller.php file and add:
var $uses = array('Configuration.Configuration');
function beforeFilter(){
//Load Configurations
$this->Configuration->load($prefix); //$prefix is 'CFG' by default
}
2) Navigate to http://www.yoursite.com/admin/configuration/configurations
3) Start adding configurations.
========================= Usage =========================
Whatever name/value pair you save in your configuration database, you'll have access to anywhere in your site via
Configure::read('[prefix].[name]'); //returns 'value';
========================= Example =========================
Say I have a configuration table like so:
__ID__|_NAME______|_VALUE_________________
1 | email | [email protected]
2 | name | Nick Baker
I could access this data anywhere in my app by simply using Configure::read([prefix].[name]);
(Default prefix is 'CFG', but you can change it in your app_controller.php).
In a view:
$html->link('Email ' . Configure::read('CFG.name'), 'mailto:' . Configure::read('CFG.email'));
In a controller:
$this->Email->from = Configure::read('CFG.email');
In a model:
$this->findByEmail(Configure::read('CFG.email');
You can get your entire Configuration table by not giving a name:
Configure::read('CFG'); //return an associative array of your configuraitons database.