[Helper] Automatically link to routes in site_url(), redirect() and anchor() |
[eluser]Phil Sturgeon[/eluser]
Setting up routes is all well and good but when you change the route you need to run around your application changing all links to it. I made a small modification that will allow you to link to the normal URI then have it output the route in the URL. An example of supported routes: Code: $route['edit-settings'] = "users/settings/edit"; You can then use: Code: <?=anchor('users/settings/edit', 'Edit Setting');?> and it will link you to http://example.com/edit-settings.html. Here is the code in the form of an extended MY_url_helper.php. Code: <?php if ( ! defined('BASEPATH')) exit('No direct script access allowed'); Note: This only works with static routes and routes using :any or :num. That means if you use regex in your route it WILL NOT WORK. This is something I will look into, but not right now. |
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
|