From 1cf89aab5fff8c8068cbf0ed18038b6e4fd4f605 Mon Sep 17 00:00:00 2001 From: admin Date: Sun, 3 Sep 2006 18:24:39 +0000 Subject: --- user_guide/general/controllers.html | 36 +++++++++++++++++++++++++++++++++++- 1 file changed, 35 insertions(+), 1 deletion(-) (limited to 'user_guide/general/controllers.html') diff --git a/user_guide/general/controllers.html b/user_guide/general/controllers.html index 4dc94cba6..3ea0b61c4 100644 --- a/user_guide/general/controllers.html +++ b/user_guide/general/controllers.html @@ -69,6 +69,7 @@ Controllers
  • What is a Controller?
  • Hello World
  • Functions
  • +
  • Remapping Function Calls
  • Private Functions
  • Defining a Default Controller
  • Organizing Controllers into Sub-folders
  • @@ -174,10 +175,43 @@ class Blog extends Controller {

    You should see your new message.

    + + +

    Remapping Function Calls

    + +

    As noted above, the second segment of the URI typically determines which function in the controller gets called. +Code Igniter permits you to override this behavior through the use of the _remap() function:

    + +function _remap()
    +{
    +    // Some code here...
    +}
    + +

    Important:  If your controller contains a function named _remap(), it will always +get called regardless of what your URI contains. It overrides the normal behavior in which the URI determines which function is called, +allowing you to define your own function routing rules.

    + +

    The overriden function call (typically the second segment of the URI) will be passed as a parameter the _remap() function:

    + +function _remap($method)
    +{
    +    if ($method == 'some_method')
    +    {
    +        $this->$method();
    +    }
    +    else
    +    {
    +        $this->default_method();
    +    }
    +}
    + + + +

    Private Functions

    -

    In some cases you may not want certain functions accessible publicly. To make a function private, simply add an +

    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:

    -- cgit v1.2.3-24-g4f1b