From c1fa07415179d63762f1a22f0f74660a8034707f Mon Sep 17 00:00:00 2001 From: admin Date: Thu, 21 Sep 2006 23:50:23 +0000 Subject: --- user_guide/general/controllers.html | 53 +++++++++++++++++++++++++++---------- 1 file changed, 39 insertions(+), 14 deletions(-) (limited to 'user_guide/general/controllers.html') diff --git a/user_guide/general/controllers.html b/user_guide/general/controllers.html index cb38a4abc..5c51f8ff0 100644 --- a/user_guide/general/controllers.html +++ b/user_guide/general/controllers.html @@ -70,9 +70,10 @@ Controllers
  • Hello World
  • Functions
  • Passing URI Segments to Your Functions
  • +
  • Defining a Default Controller
  • Remapping Function Calls
  • +
  • Controlling Output Data
  • Private Functions
  • -
  • Defining a Default Controller
  • Organizing Controllers into Sub-folders
  • Class Constructors
  • Reserved Function Names
  • @@ -204,6 +205,19 @@ class Products extends Controller {
    passed to your function will be the re-routed ones.

    + +

    Defining a Default Controller

    + +

    Code Igniter can be told to load a default controller when a URI is not present, +as will be the case when only your site root URL is requested. To specify a default controller, open +your application/config/routes.php file and set this variable:

    + +$route['default_controller'] = 'Blog'; + +

    Where Blog is the name of the controller class you want used. If you now load your main index.php file without +specifying any URI segments you'll see your Hello World message by default.

    + +

    Remapping Function Calls

    @@ -237,9 +251,33 @@ allowing you to define your own function routing rules.

    + + +

    Processing Output

    + +

    Code Igniter has an output class that takes care of sending your final rendered data to the web browser automatically. More information on this can be found in the +Views and Output class pages. In some cases, however, you might want to control +how the output gets sent to the browser, or you might want to post process the finalized data in some way. Code Igniter permits you to +add a function named _output() to your controller that will receive the finalized output data. + +

    Important:  If your controller contains a function named _output(), it will always +be called by the output class instead of echoing the finalized data directly. The first parameter of the function will contain the finalized output.

    + +

    Here is an example:

    + + +function _output($output)
    +{
    +    echo $output;
    +}
    + +

    Please note that your _output() function will receive the data in its finalized form - including rendered benchmark and memory usage data, +so if you are using this feature the page execution timer might not be perfectly accurate.

    +

    Private Functions

    +

    In some cases you may want certain functions hidden from public access. To make a function private, simply add an underscore as the name prefix and it will not be served via a URL request. For example, if you were to have a function like this:

    @@ -255,19 +293,6 @@ function _utility()
    - -

    Defining a Default Controller

    - -

    Code Igniter can be told to load a default controller when a URI is not present, -as will be the case when only your site root URL is requested. To specify a default controller, open -your application/config/routes.php file and set this variable:

    - -$route['default_controller'] = 'Blog'; - -

    Where Blog is the name of the controller class you want used. If you now load your main index.php file without -specifying any URI segments you'll see your Hello World message by default.

    - -

    Organizing Your Controllers into Sub-folders

    -- cgit v1.2.3-24-g4f1b