From 2c676ef0c7a7df9de4331137b033d236f5f3708a Mon Sep 17 00:00:00 2001 From: admin Date: Thu, 21 Sep 2006 16:54:44 +0000 Subject: --- user_guide/general/controllers.html | 33 +++++++++++++++++++++++++++++++-- 1 file changed, 31 insertions(+), 2 deletions(-) (limited to 'user_guide/general/controllers.html') diff --git a/user_guide/general/controllers.html b/user_guide/general/controllers.html index 5511efbf2..cb38a4abc 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
  • +
  • Passing URI Segments to Your Functions
  • Remapping Function Calls
  • Private Functions
  • Defining a Default Controller
  • @@ -175,6 +176,34 @@ class Blog extends Controller {

    You should see your new message.

    + +

    Passing URI Segments to your Functions

    + +

    If your URI contains more then two segments they will be passed to your function as parameters.

    + +

    For example, lets say you have a URI like this: + +www.your-site.com/index.php/products/shoes/sandals/123 + +

    Your function will be passed URI segments 3 and 4 ("sandals" and "123"):

    + + +<?php
    +class Products extends Controller {
    +
    +    function shoes($sandals, $id)
    +    {
    +        echo $sandals;
    +        echo $id;
    +    }
    +}
    +?> +
    + +

    Important:  If you are using the URI Routing feature, the segments +passed to your function will be the re-routed ones.

    + +

    Remapping Function Calls

    @@ -191,7 +220,7 @@ Code Igniter permits you to override this behavior through the use of the _ 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:

    +

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

    function _remap($method)
    {
    @@ -275,7 +304,7 @@ called if the URL contains only the sub-folder. Simply name your default contro

    The reason this line is necessary is because your local constructor will be overriding the one in the parent controller class so we need to manually call it.

    -

    If you are not familliar with constructors, in PHP 4, a constructor is simply a function that has the exact same name as the class:

    +

    If you are not familiar with constructors, in PHP 4, a constructor is simply a function that has the exact same name as the class:

    <?php
    -- cgit v1.2.3-24-g4f1b