[Helper] Automatically link to routes in site_url(), redirect() and anchor() |
[eluser]zentair[/eluser]
I've made some improvements and modifications to this function: 1) Get the routes via $CI->router->routes 2) Match everything between parentheses 3) used preg_split and simply swap the even numbered matches 4) break after finding a match, this is required because in the Router higher routes will always take precedence over lower ones (http://ellislab.com/codeigniter/user-gui...uting.html). 5) I also added the functionality in http://ellislab.com/forums/viewthread/167695/ This works fine for routes like: Code: $route['view/(:any)/(:num)'] = 'entries/view/$1/$2'; It does not work for routes that use expressions without parentheses Code: $route['product/:num'] = "catalog/product_lookup"; Code: function site_url($uri = '') Update: After discovering my site_url() calls were rewritten but form_open() wasn't I think it's better to add this functionality to the config class after all, config->site_url() is used by more helpers and libraries. |
Messages In This Thread |
[Helper] Automatically link to routes in site_url(), redirect() and anchor() - by El Forum - 01-15-2009, 06:53 AM
[Helper] Automatically link to routes in site_url(), redirect() and anchor() - by El Forum - 01-15-2009, 06:58 AM
[Helper] Automatically link to routes in site_url(), redirect() and anchor() - by El Forum - 01-15-2009, 08:33 AM
[Helper] Automatically link to routes in site_url(), redirect() and anchor() - by El Forum - 01-16-2009, 06:06 AM
[Helper] Automatically link to routes in site_url(), redirect() and anchor() - by El Forum - 08-07-2011, 07:55 AM
[Helper] Automatically link to routes in site_url(), redirect() and anchor() - by El Forum - 08-09-2011, 01:55 PM
[Helper] Automatically link to routes in site_url(), redirect() and anchor() - by El Forum - 08-10-2011, 01:20 AM
|