New version submitted by TomB
[carbonphp.git] / Documentation / libraries / loader.html
blob87fcc4238c1e72e02f946f3d33e7d80c95e7345c
1 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
2 <head>
3 <title>CarbonPHP Documentation</title>
4 <style type="text/css">
5 * {
6 margin: 0;
7 padding: 0;
10 html {
11 font-family: "Lucida Sans Unicode", "Lucida Grande";
12 font-size: 12px;
15 body {
16 background: #fff;
17 color: #666;
20 h1 {
21 font-size: 15px;
22 font-weight: bold;
23 margin: 0 0 5px 0;
26 h2 {
27 font-size: 13px;
28 font-weight: bold;
29 margin: 5px 0 5px 0;
32 ol, ul {
33 margin: 10px 0 10px 0;
34 list-style-position: inside;
37 p {
38 margin: 5px 0 5px 0;
41 .content {
42 border: 1px dotted #444;
43 margin: 10px;
44 padding: 10px;
45 text-align: justify;
46 width: 700px;
49 .example {
50 border: 1px solid #ccc;
51 background: #eee;
52 margin: 10px;
53 padding: 10px;
55 </style>
56 </head>
58 <body>
59 <div class="content">
60 <h1>Loader Library</h1>
62 <p>This is the class that loads the various elements within the framework. These elements can be, models,
63 views, utilities, and even your own files.</p>
65 <p><i>Note</i>: this library is loaded automatically by CarbonPHP.</p>
66 </div>
68 <div class="content">
69 <h1>$this->load->library('class_name')</h1>
71 <p>This method loads the core CarbonPHP libraries. <b>class_name</b> is the name of the class you wish to
72 load. For example if you wish to load the pagination library you would do the following.</p>
74 <div class="example">
75 $this->load->library('<b>pagination</b>');
76 </div>
78 <p>Once the library has been loaded it will be accessible via the object in the <b>$this</b> object. Each
79 library is outlined on its own page.</p>
80 </div>
82 <div class="content">
83 <h1>$this->load->view('view_name', $data, true/false)</h1>
85 <p>This method is used to load a view file. The first parameter is required and is the name of the view file
86 to load without the file extension.</p>
88 <p>The second parameter is an optional parameter that can take an array or an object, which it runs through
89 the PHP function <b>extract</b> to convert to variables that can be accessed in the view file.</p>
91 <p>The third parameter is another optional parameter that changes how the method returns. If the parameter
92 is set to <b>true</b> the method will return the data instead of sending it to the browser.</p>
94 <div class="example">
95 $data = $this->load->view('<b>myview</b>', '', <b>true</b>);
96 </div>
97 </div>
99 <div class="content">
100 <h1>$this->load->database('options', true/false)</h1>
102 <p>This method loads the database class which connects to a database. This method is outlined more in the
103 database pages.</p>
104 </div>
106 <div class="content">
107 <h1>$this->load->scaffolding('table_name')</h1>
109 <p>This method enables scaffolding. This method is outlined more in the scaffolding page.</p>
110 </div>
112 <div class="content">
113 <h1>$this->load->var($array)</h1>
115 <p>This method takes an array as input and generates variables. This method produces the same result as
116 using the second parameter of <b>$this->load->view()</b> explained above. The main reason you may wish to
117 use this is if you wish to set some global variables in the constructor of your controller and have them
118 become available in any view file.</p>
119 </div>
121 <div class="content">
122 <h1>$this->load->utility('file_name')</h1>
124 <p>This method loads any utility files, where <b>file_name</b> is the name of the utility without the
125 <b>_utility.php</b> on the end.</p>
126 </div>
128 <div class="content">
129 <h1>$this->load->file('filepath/filename', true/false)</h1>
131 <p>This method will load any file. If the second parameter is set to <b>true</b> the data from the file will
132 be returned as a string, instead of being sent to the browser.</p>
133 </div>
135 <div class="content">
136 <h1>$this->load->language('file_name')</h1>
138 <p>This method is an alias of the <b>$this->lang->load()</b> method.</p>
139 </div>
141 <div class="content">
142 <h1>$this->load->config('file_name')</h1>
144 <p>This method is an alias of the <b>$this->config->load()</b> method.</p>
145 </div>
146 </body>
148 </html>