/ Published in: PHP
Just save this as MY_Router.php and upload to application/core/ and now you'll be able to use us :alpha along with :num and :any in your routes to signify that you just want to match a-z.
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
/** * CodeIgniter * * An open source application development framework for PHP 5.1.6 or newer * * @package CodeIgniter * @author ExpressionEngine Dev Team * @copyright Copyright (c) 2008 - 2011, EllisLab, Inc. * @license http://codeigniter.com/user_guide/license.html * @link http://codeigniter.com * @since Version 1.0 * @filesource */ // ------------------------------------------------------------------------ /** * Router Class * * Parses URIs and determines routing * * @package CodeIgniter * @subpackage Libraries * @author ExpressionEngine Dev Team * @category Libraries * @link http://codeigniter.com/user_guide/general/routing.html */ class MY_Router extends CI_Router { function __construct() { parent::__construct(); } /** * Parse Routes * * This function matches any routes that may exist in * the config/routes.php file against the URI to * determine if the class/method need to be remapped. * * @access private * @return void */ function _parse_routes() { // Turn the segment array into a URI string // Is there a literal match? If so we're done { } // Loop through the route array looking for wild-cards foreach ($this->routes as $key => $val) { /* // OLD CODEIGNITER WILD-CARD REGEX // Convert wild-cards to RegEx $key = str_replace(':any', '.+', str_replace(':num', '[0-9]+', $key)); */ // Convert wild-cards to RegEx // Additionally added :alpha to the wild cards. // @Author Josh Manders // @Website joshmanders.com foreach ($wild_cards as $wild_card => $regex) { } // Does the RegEx match? { // Do we have a back-reference? { } } } // If we got this far it means we didn't encounter a // matching route so we'll set the site default route $this->_set_request($this->uri->segments); } } // END Router Class /* End of file MY_Router.php */ /* Location: ./app/core/MY_Router.php */