diff options
author | admin <devnull@localhost> | 2006-09-21 18:54:44 +0200 |
---|---|---|
committer | admin <devnull@localhost> | 2006-09-21 18:54:44 +0200 |
commit | 2c676ef0c7a7df9de4331137b033d236f5f3708a (patch) | |
tree | 62c8367ffaefc3a7767aae799314c81efe5c5601 /user_guide/general/controllers.html | |
parent | 30e8e292697d60a5379b4cb37f02f44fd9918cf1 (diff) |
Diffstat (limited to 'user_guide/general/controllers.html')
-rw-r--r-- | user_guide/general/controllers.html | 33 |
1 files changed, 31 insertions, 2 deletions
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 <li><a href="#what">What is a Controller?</a></li>
<li><a href="#hello">Hello World</a></li>
<li><a href="#functions">Functions</a></li>
+<li><a href="#passinguri">Passing URI Segments to Your Functions</a></li>
<li><a href="#remapping">Remapping Function Calls</a></li>
<li><a href="#private">Private Functions</a></li>
<li><a href="#default">Defining a Default Controller</a></li>
@@ -175,6 +176,34 @@ class Blog extends Controller { <p>You should see your new message.</p>
+<a name="passinguri"></a>
+<h2>Passing URI Segments to your Functions</h2>
+
+<p>If your URI contains more then two segments they will be passed to your function as parameters.</p>
+
+<p>For example, lets say you have a URI like this:
+
+<code>www.your-site.com/index.php/<var>products</var>/<samp>shoes</samp>/<kbd>sandals</kbd>/<dfn>123</dfn></code>
+
+<p>Your function will be passed URI segments 3 and 4 ("sandals" and "123"):</p>
+
+<code>
+<?php<br />
+class Products extends Controller {<br />
+<br />
+ function shoes($sandals, $id)<br />
+ {<br />
+ echo $sandals;<br />
+ echo $id;<br />
+ }<br />
+}<br />
+?>
+</code>
+
+<p class="important"><strong>Important:</strong> If you are using the <a href="routing.html">URI Routing</a> feature, the segments
+passed to your function will be the re-routed ones.</p>
+
+
<a name="remapping"></a>
<h2>Remapping Function Calls</h2>
@@ -191,7 +220,7 @@ Code Igniter permits you to override this behavior through the use of the <kbd>_ 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.</p>
-<p>The overriden function call (typically the second segment of the URI) will be passed as a parameter the <kbd>_remap()</kbd> function:</p>
+<p>The overridden function call (typically the second segment of the URI) will be passed as a parameter the <kbd>_remap()</kbd> function:</p>
<code>function _remap(<var>$method</var>)<br />
{<br />
@@ -275,7 +304,7 @@ called if the URL contains only the sub-folder. Simply name your default contro <p>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.</p>
-<p>If you are not familliar with constructors, in PHP 4, a <em>constructor</em> is simply a function that has the exact same name as the class:</p>
+<p>If you are not familiar with constructors, in PHP 4, a <em>constructor</em> is simply a function that has the exact same name as the class:</p>
<code>
<?php<br />
|