Welcome Guest, Not a member yet? Register   Sign In
routing question
#1

[eluser]keevitaja[/eluser]
i have a controller named contacts.php with routing

Code:
$route['contacts/(:num)'] = "contacts/index/$1";

for the use of the second segment in the index method

i need to add 3rd segment for the pagination as, contacts/1/3

how should i route this?
#2

[eluser]keevitaja[/eluser]
Code:
$route['(:any)'] = 'home/index/$1';
$route['user/urls'] = 'user/urls';
$route['user/urls/(:any)'] = 'user/urls/$1';

somehow the last routing is not working, while user/urls is working.

controller is user with method public function urls($offset = 0)

why can't i route this? or is there another way to do it? i need the first rule!
#3

[eluser]keevitaja[/eluser]
anyone?

i'll try to explain more

site.com/hdqat

the first segment is the 5 to 10 letter random string, which will be user to direct user to the specific page. that's why i need this first rule from my previous post. but i still want to usu controller user with method url where $1 is page number.

2nd route is to override the first one. if i remove first rule, i can use the controllers!

what am i doing wrong?
#4

[eluser]CroNiX[/eluser]
Try reversing all of your routes from 2 posts up.
They should be in order of most specific/segments to most general, as the very first matched route is what will be used.

In other words, ANY route that starts with "/user/urls" will be triggered the first rule, even if there are additional segments, so the 2nd rule dealing with "/user/urls/(:any)" you have there will never be triggered.
#5

[eluser]keevitaja[/eluser]
Code:
$route['user/(:any)/(:any)'] = 'user/$1/$1';
$route['user/urls'] = 'user/urls';
$route['(:any)'] = 'home/index/$1';

think i got it. this is the order i need. thanx
#6

[eluser]InsiteFX[/eluser]
This should be
Code:
route['user/(:any)/(:any)'] = 'user/$1/$2';




Theme © iAndrew 2016 - Forum software by © MyBB