Created
July 5, 2011 21:59
-
-
Save joshhartman/1066067 to your computer and use it in GitHub Desktop.
Modify CodeIgniter to Support Hyphens in URL Request Segment
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| /* | |
| | | |
| | Put this file (MY_Router.php) inside /application/core (CI2) | |
| | Remember that this will effect all segments, not only module, controller and method. | |
| | | |
| | Alternative to this extend is to add each segment to application/config/routes.php | |
| | $route['this-is-a-module-or-controler'] = 'this_is_a_module_or_controller'; | |
| | | |
| | As you can see the extend method would be easier to use. You can choose to make | |
| | the function also to handle only the first two or three segments so that the other | |
| | segments are not affected with the '_' replacement. | |
| | | |
| */ | |
| class MY_Router extends CI_Router | |
| { | |
| function _set_request($segments = array()) { | |
| parent::_set_request(str_replace('-', '_', $segments)); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment