summaryrefslogtreecommitdiffstats
path: root/user_guide/general/controllers.html
diff options
context:
space:
mode:
Diffstat (limited to 'user_guide/general/controllers.html')
-rw-r--r--user_guide/general/controllers.html33
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>
+&lt;?php<br />
+class Products extends Controller {<br />
+<br />
+&nbsp;&nbsp;&nbsp;&nbsp;function shoes($sandals, $id)<br />
+&nbsp;&nbsp;&nbsp;&nbsp;{<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;echo $sandals;<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;echo $id;<br />
+&nbsp;&nbsp;&nbsp;&nbsp;}<br />
+}<br />
+?&gt;
+</code>
+
+<p class="important"><strong>Important:</strong>&nbsp; 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>
&lt;?php<br />