From 1cf89aab5fff8c8068cbf0ed18038b6e4fd4f605 Mon Sep 17 00:00:00 2001 From: admin Date: Sun, 3 Sep 2006 18:24:39 +0000 Subject: --- user_guide/general/changelog.html | 2 ++ user_guide/general/controllers.html | 36 +++++++++++++++++++++++++++++++++++- 2 files changed, 37 insertions(+), 1 deletion(-) (limited to 'user_guide/general') diff --git a/user_guide/general/changelog.html b/user_guide/general/changelog.html index 168e72fef..370cd0447 100644 --- a/user_guide/general/changelog.html +++ b/user_guide/general/changelog.html @@ -71,6 +71,7 @@ Change Log
  • Added Hooks feature, enabling you to tap into and modify the inner workings of the framework without hacking the core files.
  • Added the ability to organize controller files into sub-folders. Kudos to Marco for suggesting this (and the next two) feature.
  • Added regular expressions support for routing rules.
  • +
  • Added the ability to remap function calls withing your controllers.
  • Added the ability to replace core system classes with your own classes.
  • Added support for % character in URL.
  • Added the ability to supply full URLs using the anchor() helper function.
  • @@ -107,6 +108,7 @@ Change Log
  • Fixed a bug in the set_hash() function which was preventing MD5 from being used.
  • Fixed a couple bugs in the Unit Testing class.
  • Fixed an incorrectly named variable in the Validation class.
  • +
  • Fixed an incorrectly named variable in the URI class.
  • Fixed some MS SQL bugs.
  • Fixed some doc typos.
  • 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