summaryrefslogtreecommitdiffstats
path: root/user_guide/general
diff options
context:
space:
mode:
Diffstat (limited to 'user_guide/general')
-rw-r--r--user_guide/general/changelog.html2
-rw-r--r--user_guide/general/controllers.html36
2 files changed, 37 insertions, 1 deletions
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
<li>Added <a href="hooks.html">Hooks</a> feature, enabling you to tap into and modify the inner workings of the framework without hacking the core files.</li>
<li>Added the ability to organize controller files <a href="controllers.html">into sub-folders</a>. Kudos to Marco for <a href="http://www.codeigniter.com/forums/viewthread/627/">suggesting</a> this (and the next two) feature.</li>
<li>Added regular expressions support for <a href="routing.html">routing rules</a>.</li>
+<li>Added the ability to <a href="controllers.html">remap function calls</a> withing your controllers.</li>
<li>Added the ability to <a href="core_classes.html">replace core system classes</a> with your own classes.</li>
<li>Added support for % character in URL.</li>
<li>Added the ability to supply full URLs using the <a href="../helpers/url_helper.html">anchor()</a> helper function.</li>
@@ -107,6 +108,7 @@ Change Log
<li>Fixed a bug in the <dfn>set_hash()</dfn> function which was preventing MD5 from being used.</li>
<li>Fixed a couple bugs in the Unit Testing class.</li>
<li>Fixed an incorrectly named variable in the Validation class.</li>
+<li>Fixed an incorrectly named variable in the URI class.</li>
<li>Fixed some MS SQL bugs.</li>
<li>Fixed some doc typos.</li>
</ul>
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
<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="#remapping">Remapping Function Calls</a></li>
<li><a href="#private">Private Functions</a></li>
<li><a href="#default">Defining a Default Controller</a></li>
<li><a href="#subfolders">Organizing Controllers into Sub-folders</a></li>
@@ -174,10 +175,43 @@ class Blog extends Controller {
<p>You should see your new message.</p>
+
+<a name="remapping"></a>
+<h2>Remapping Function Calls</h2>
+
+<p>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 <kbd>_remap()</kbd> function:</p>
+
+<code>function _remap()<br />
+{<br />
+&nbsp;&nbsp;&nbsp;&nbsp;// Some code here...<br />
+}</code>
+
+<p class="important"><strong>Important:</strong>&nbsp; If your controller contains a function named <kbd>_remap()</kbd>, it will <strong>always</strong>
+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>
+
+<code>function _remap(<var>$method</var>)<br />
+{<br />
+&nbsp;&nbsp;&nbsp;&nbsp;if ($method == 'some_method')<br />
+&nbsp;&nbsp;&nbsp;&nbsp;{<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$this->$method();<br />
+&nbsp;&nbsp;&nbsp;&nbsp;}<br />
+&nbsp;&nbsp;&nbsp;&nbsp;else<br />
+&nbsp;&nbsp;&nbsp;&nbsp;{<br />
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$this->default_method();<br />
+&nbsp;&nbsp;&nbsp;&nbsp;}<br />
+}</code>
+
+
+
+
<a name="private"></a>
<h2>Private Functions</h2>
-<p>In some cases you may not want certain functions accessible publicly. To make a function private, simply add an
+<p>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:</p>
<code>