From b0dd10f8171945e0c1f3527dd1e9d18b043e01a7 Mon Sep 17 00:00:00 2001 From: admin Date: Fri, 25 Aug 2006 17:25:49 +0000 Subject: Initial Import --- user_guide/libraries/loader.html | 171 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 171 insertions(+) create mode 100644 user_guide/libraries/loader.html (limited to 'user_guide/libraries/loader.html') diff --git a/user_guide/libraries/loader.html b/user_guide/libraries/loader.html new file mode 100644 index 000000000..630a2ea6f --- /dev/null +++ b/user_guide/libraries/loader.html @@ -0,0 +1,171 @@ + + + + +Code Igniter User Guide + + + + + + + + + + + + + + + + + + + + + + +
+ + + + + +

Code Igniter User Guide Version 1.4.0

+
+ + + + + + + + + +
+ + +
+ + + +
+ + +

Loader Class

+ +

Loader, as the name suggests, is used to load elements. These elements can be libraries (classes) View files, +Helpers, Plugins, or your own files.

+ +

Note: This class is initialized automatically by the system so there is no need to do it manually.

+ +

The following functions are available in this class:

+ + + +

$this->load->view('file_name', $data, true/false)

+ +

This function is used to load your View files. If you haven't read the Views section of the +user guide it is recommended that you do since it shows you how this function is typically used.

+ +

The first parameter is required. It is the name of the view file you would like to load.

+ +

The second optional parameter can take +an associative array or an object as input, which it runs through the PHP extract function to +convert to variables that can be used in your view files. Again, read the Views page to learn +how this might be useful.

+ +

The third optional parameter lets you change the behavior of the function so that it returns data as a string +rather than sending it to your browser. This can be useful if you want to process the data in some way. If you +set the parameter to true (boolean) it will return data. The default behavior is false, which sends it +to your browser. Remember to assign it to a variable if you wan the data returned:

+ +$string = $this->load->view('myfile', '', true); + + + +

$this->load->library('class_name')

+ +

This function is used to load core classes. Where class_name is the name of the class you want to load. +Note: We use the terms "class" and "library" interchangeably.

+ +

For example, if you would like to send email with Code Igniter, the first step is to load the email class within your controller:

+ +$this->load->library('email'); + +

Once loaded, the library will be ready for use. Each library is described in detail in its own page, so please read the +information regarding each one you would like to use.

+ + + +

$this->load->database('options', true/false)

+ +

This function lets you load the database class. The two parameters are optional. Please see the +database section for more info.

+ + +

$this->load->scaffolding('table_name')

+ +

This function lets you enable scaffolding. Please see the +scaffolding section for more info.

+ + + +

$this->load->vars($array)

+ +

This function takes an associative array as input and generates variables using the PHP extract function. +This function produces the same result as using the second parameter of the $this->load->view() function above. The reason you might +want to use this function independently is if you would like to set some global variables in the constructor of your controller +and have them become available in any view file loaded from any function. You can have multiple calls to this function. The data get cached +and merged into one array for conversion to variables. +

+ + +

$this->load->helper('file_name')

+

This function loads helper files, where file_name is the name of the file, without the _helper.php extension.

+ + +

$this->load->plugin('file_name')

+

This function loads plugins files, where file_name is the name of the file, without the _plugin.php extension.

+ +

$this->load->file('filepath/filename', true/false)

+

This is a generic file loading function. Supply the filepath and name in the first parameter and it will open and read the file. +By default the data is sent to your browser, just like a View file, but if you set the second parameter to true (boolean) +it will instead return the data as a string.

+ + +

$this->load->lang('file_name')

+

This function is an alias of the language loading function: $this->lang->load()

+ +

$this->load->config('file_name')

+

This function is an alias of the config file loading function: $this->config->load()

+ + + + +
+ + + + + + + \ No newline at end of file -- cgit v1.2.3-24-g4f1b