Welcome Guest, Not a member yet? Register   Sign In
Routing changes at a single location
#1

(This post was last modified: 10-18-2016, 07:26 PM by ciadmin.)

I've recently started using CI and find it really difficult to perform routing changes. Whether I want to specify a form action, or want to redirect to a page, I have to specify some URL fragment, and at a later point, if I decide to make changes to route, I have to find each usage and replace it. How can I avoid doing this?
Reply
#2

(10-18-2016, 12:35 PM)RBX Wrote: I've recently started using CI and find it really difficult to perform routing changes. Whether I want to specify a form action, or want to redirect to a page, I have to specify some URL fragment, and at a later point, if I decide to make changes to route, I have to find each usage and replace it. How can I avoid doing this?

Did you try (:num) and (:any) regexes ?
Reply
#3

(This post was last modified: 10-22-2016, 12:33 PM by RBX.)

(10-21-2016, 03:02 AM)d4jk4 Wrote:
(10-18-2016, 12:35 PM)RBX Wrote: I've recently started using CI and find it really difficult to perform routing changes. Whether I want to specify a form action, or want to redirect to a page, I have to specify some URL fragment, and at a later point, if I decide to make changes to route, I have to find each usage and replace it. How can I avoid doing this?

Did you try (:num) and (:any) regexes ?

I use them, but I don't see how they can help in changing
rewards/cart/(:num)/add to cart/add/(:num).

I've been thinking about 'naming' my routes so I could something like
PHP Code:
$route[ADD_TO_CART'(:num)'] = 'controller/action';
echo 
form_open(ADD_TO_CART.$id); 
but it effectively limits the wildcards to the end of the route.

Edit: I just read a blog post on CI4 which says named routes are coming. I wish some of these changes could be made to CI3 routes too, at least to turn the magic routing off.
Reply




Theme © iAndrew 2016 - Forum software by © MyBB